1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Enterprise Fibre Channel Host Bus Adapters. *
4 * Refer to the README file included with this package for *
5 * driver version and adapter support. *
6 * Copyright (C) 2004 Emulex Corporation. *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU General Public License *
11 * as published by the Free Software Foundation; either version 2 *
12 * of the License, or (at your option) any later version. *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details, a copy of which *
18 * can be found in the file COPYING included with this package. *
19 *******************************************************************/
22 * $Id: lpfc_sli.c 1.232 2005/04/13 11:59:16EDT sf_support Exp $
25 #include <linux/blkdev.h>
26 #include <linux/pci.h>
27 #include <linux/interrupt.h>
28 #include <linux/delay.h>
30 #include <scsi/scsi_cmnd.h>
31 #include <scsi/scsi_device.h>
32 #include <scsi/scsi_host.h>
36 #include "lpfc_disc.h"
37 #include "lpfc_scsi.h"
39 #include "lpfc_crtn.h"
40 #include "lpfc_logmsg.h"
41 #include "lpfc_compat.h"
44 * Define macro to log: Mailbox command x%x cannot issue Data
45 * This allows multiple uses of lpfc_msgBlk0311
46 * w/o perturbing log msg utility.
48 #define LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) \
49 lpfc_printf_log(phba, \
52 "%d:0311 Mailbox command x%x cannot issue " \
53 "Data: x%x x%x x%x\n", \
61 /* There are only four IOCB completion types. */
62 typedef enum _lpfc_iocb_type
{
70 * Translate the iocb command to an iocb command type used to decide the final
71 * disposition of each completed IOCB.
74 lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd
)
76 lpfc_iocb_type type
= LPFC_UNKNOWN_IOCB
;
78 if (iocb_cmnd
> CMD_MAX_IOCB_CMD
)
82 case CMD_XMIT_SEQUENCE_CR
:
83 case CMD_XMIT_SEQUENCE_CX
:
84 case CMD_XMIT_BCAST_CN
:
85 case CMD_XMIT_BCAST_CX
:
86 case CMD_ELS_REQUEST_CR
:
87 case CMD_ELS_REQUEST_CX
:
88 case CMD_CREATE_XRI_CR
:
89 case CMD_CREATE_XRI_CX
:
91 case CMD_XMIT_ELS_RSP_CX
:
93 case CMD_FCP_IWRITE_CR
:
94 case CMD_FCP_IWRITE_CX
:
95 case CMD_FCP_IREAD_CR
:
96 case CMD_FCP_IREAD_CX
:
97 case CMD_FCP_ICMND_CR
:
98 case CMD_FCP_ICMND_CX
:
100 case CMD_ADAPTER_DUMP
:
101 case CMD_XMIT_SEQUENCE64_CR
:
102 case CMD_XMIT_SEQUENCE64_CX
:
103 case CMD_XMIT_BCAST64_CN
:
104 case CMD_XMIT_BCAST64_CX
:
105 case CMD_ELS_REQUEST64_CR
:
106 case CMD_ELS_REQUEST64_CX
:
107 case CMD_FCP_IWRITE64_CR
:
108 case CMD_FCP_IWRITE64_CX
:
109 case CMD_FCP_IREAD64_CR
:
110 case CMD_FCP_IREAD64_CX
:
111 case CMD_FCP_ICMND64_CR
:
112 case CMD_FCP_ICMND64_CX
:
113 case CMD_GEN_REQUEST64_CR
:
114 case CMD_GEN_REQUEST64_CX
:
115 case CMD_XMIT_ELS_RSP64_CX
:
116 type
= LPFC_SOL_IOCB
;
118 case CMD_ABORT_XRI_CN
:
119 case CMD_ABORT_XRI_CX
:
120 case CMD_CLOSE_XRI_CN
:
121 case CMD_CLOSE_XRI_CX
:
122 case CMD_XRI_ABORTED_CX
:
123 case CMD_ABORT_MXRI64_CN
:
124 type
= LPFC_ABORT_IOCB
;
126 case CMD_RCV_SEQUENCE_CX
:
127 case CMD_RCV_ELS_REQ_CX
:
128 case CMD_RCV_SEQUENCE64_CX
:
129 case CMD_RCV_ELS_REQ64_CX
:
130 type
= LPFC_UNSOL_IOCB
;
133 type
= LPFC_UNKNOWN_IOCB
;
141 lpfc_sli_ring_map(struct lpfc_hba
* phba
, LPFC_MBOXQ_t
*pmb
)
143 struct lpfc_sli
*psli
= &phba
->sli
;
144 MAILBOX_t
*pmbox
= &pmb
->mb
;
147 for (i
= 0; i
< psli
->num_rings
; i
++) {
148 phba
->hba_state
= LPFC_INIT_MBX_CMDS
;
149 lpfc_config_ring(phba
, i
, pmb
);
150 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_POLL
);
151 if (rc
!= MBX_SUCCESS
) {
152 lpfc_printf_log(phba
,
155 "%d:0446 Adapter failed to init, "
156 "mbxCmd x%x CFG_RING, mbxStatus x%x, "
162 phba
->hba_state
= LPFC_HBA_ERROR
;
170 lpfc_sli_ringtxcmpl_put(struct lpfc_hba
* phba
,
171 struct lpfc_sli_ring
* pring
, struct lpfc_iocbq
* piocb
)
175 list_add_tail(&piocb
->list
, &pring
->txcmplq
);
176 pring
->txcmplq_cnt
++;
177 if (unlikely(pring
->ringno
== LPFC_ELS_RING
))
178 mod_timer(&phba
->els_tmofunc
,
179 jiffies
+ HZ
* (phba
->fc_ratov
<< 1));
181 if (pring
->fast_lookup
) {
182 /* Setup fast lookup based on iotag for completion */
183 iotag
= piocb
->iocb
.ulpIoTag
;
184 if (iotag
&& (iotag
< pring
->fast_iotag
))
185 *(pring
->fast_lookup
+ iotag
) = piocb
;
188 /* Cmd ring <ringno> put: iotag <iotag> greater then
189 configured max <fast_iotag> wd0 <icmd> */
190 lpfc_printf_log(phba
,
193 "%d:0316 Cmd ring %d put: iotag x%x "
194 "greater then configured max x%x "
197 pring
->ringno
, iotag
,
199 *(((uint32_t *)(&piocb
->iocb
)) + 7));
205 static struct lpfc_iocbq
*
206 lpfc_sli_ringtx_get(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
)
208 struct list_head
*dlp
;
209 struct lpfc_iocbq
*cmd_iocb
;
213 list_remove_head((&pring
->txq
), cmd_iocb
,
217 /* If the first ptr is not equal to the list header,
218 * deque the IOCBQ_t and return it.
226 lpfc_sli_next_iocb_slot (struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
)
228 MAILBOX_t
*mbox
= (MAILBOX_t
*)phba
->sli
.MBhostaddr
;
229 PGP
*pgp
= (PGP
*)&mbox
->us
.s2
.port
[pring
->ringno
];
230 uint32_t max_cmd_idx
= pring
->numCiocb
;
233 if ((pring
->next_cmdidx
== pring
->cmdidx
) &&
234 (++pring
->next_cmdidx
>= max_cmd_idx
))
235 pring
->next_cmdidx
= 0;
237 if (unlikely(pring
->local_getidx
== pring
->next_cmdidx
)) {
239 pring
->local_getidx
= le32_to_cpu(pgp
->cmdGetInx
);
241 if (unlikely(pring
->local_getidx
>= max_cmd_idx
)) {
242 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
243 "%d:0315 Ring %d issue: portCmdGet %d "
244 "is bigger then cmd ring %d\n",
245 phba
->brd_no
, pring
->ringno
,
246 pring
->local_getidx
, max_cmd_idx
);
248 phba
->hba_state
= LPFC_HBA_ERROR
;
250 * All error attention handlers are posted to
253 phba
->work_ha
|= HA_ERATT
;
254 phba
->work_hs
= HS_FFER3
;
256 wake_up(phba
->work_wait
);
261 if (pring
->local_getidx
== pring
->next_cmdidx
)
265 iocb
= IOCB_ENTRY(pring
->cmdringaddr
, pring
->cmdidx
);
271 lpfc_sli_next_iotag(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
)
273 uint32_t search_start
;
275 if (pring
->fast_lookup
== NULL
) {
277 if (pring
->iotag_ctr
>= pring
->iotag_max
)
278 pring
->iotag_ctr
= 1;
279 return pring
->iotag_ctr
;
282 search_start
= pring
->iotag_ctr
;
286 if (pring
->iotag_ctr
>= pring
->fast_iotag
)
287 pring
->iotag_ctr
= 1;
289 if (*(pring
->fast_lookup
+ pring
->iotag_ctr
) == NULL
)
290 return pring
->iotag_ctr
;
292 } while (pring
->iotag_ctr
!= search_start
);
295 * Outstanding I/O count for ring <ringno> is at max <fast_iotag>
297 lpfc_printf_log(phba
,
300 "%d:0318 Outstanding I/O count for ring %d is at max x%x\n",
308 lpfc_sli_submit_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
309 IOCB_t
*iocb
, struct lpfc_iocbq
*nextiocb
)
312 * Allocate and set up an iotag
314 nextiocb
->iocb
.ulpIoTag
=
315 lpfc_sli_next_iotag(phba
, &phba
->sli
.ring
[phba
->sli
.fcp_ring
]);
318 * Issue iocb command to adapter
320 lpfc_sli_pcimem_bcopy(&nextiocb
->iocb
, iocb
, sizeof (IOCB_t
));
322 pring
->stats
.iocb_cmd
++;
325 * If there is no completion routine to call, we can release the
326 * IOCB buffer back right now. For IOCBs, like QUE_RING_BUF,
327 * that have no rsp ring completion, iocb_cmpl MUST be NULL.
329 if (nextiocb
->iocb_cmpl
)
330 lpfc_sli_ringtxcmpl_put(phba
, pring
, nextiocb
);
332 list_add_tail(&nextiocb
->list
, &phba
->lpfc_iocb_list
);
336 * Let the HBA know what IOCB slot will be the next one the
337 * driver will put a command into.
339 pring
->cmdidx
= pring
->next_cmdidx
;
340 writeb(pring
->cmdidx
, phba
->MBslimaddr
341 + (SLIMOFF
+ (pring
->ringno
* 2)) * 4);
345 lpfc_sli_update_full_ring(struct lpfc_hba
* phba
,
346 struct lpfc_sli_ring
*pring
)
348 int ringno
= pring
->ringno
;
350 pring
->flag
|= LPFC_CALL_RING_AVAILABLE
;
355 * Set ring 'ringno' to SET R0CE_REQ in Chip Att register.
356 * The HBA will tell us when an IOCB entry is available.
358 writel((CA_R0ATT
|CA_R0CE_REQ
) << (ringno
*4), phba
->CAregaddr
);
359 readl(phba
->CAregaddr
); /* flush */
361 pring
->stats
.iocb_cmd_full
++;
365 lpfc_sli_update_ring(struct lpfc_hba
* phba
,
366 struct lpfc_sli_ring
*pring
)
368 int ringno
= pring
->ringno
;
371 * Tell the HBA that there is work to do in this ring.
374 writel(CA_R0ATT
<< (ringno
* 4), phba
->CAregaddr
);
375 readl(phba
->CAregaddr
); /* flush */
379 lpfc_sli_resume_iocb(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
)
382 struct lpfc_iocbq
*nextiocb
;
386 * (a) there is anything on the txq to send
388 * (c) link attention events can be processed (fcp ring only)
389 * (d) IOCB processing is not blocked by the outstanding mbox command.
391 if (pring
->txq_cnt
&&
392 (phba
->hba_state
> LPFC_LINK_DOWN
) &&
393 (pring
->ringno
!= phba
->sli
.fcp_ring
||
394 phba
->sli
.sli_flag
& LPFC_PROCESS_LA
) &&
395 !(pring
->flag
& LPFC_STOP_IOCB_MBX
)) {
397 while ((iocb
= lpfc_sli_next_iocb_slot(phba
, pring
)) &&
398 (nextiocb
= lpfc_sli_ringtx_get(phba
, pring
)))
399 lpfc_sli_submit_iocb(phba
, pring
, iocb
, nextiocb
);
402 lpfc_sli_update_ring(phba
, pring
);
404 lpfc_sli_update_full_ring(phba
, pring
);
410 /* lpfc_sli_turn_on_ring is only called by lpfc_sli_handle_mb_event below */
412 lpfc_sli_turn_on_ring(struct lpfc_hba
* phba
, int ringno
)
416 (((MAILBOX_t
*)phba
->sli
.MBhostaddr
)->us
.s2
.port
[ringno
]));
418 /* If the ring is active, flag it */
419 if (phba
->sli
.ring
[ringno
].cmdringaddr
) {
420 if (phba
->sli
.ring
[ringno
].flag
& LPFC_STOP_IOCB_MBX
) {
421 phba
->sli
.ring
[ringno
].flag
&= ~LPFC_STOP_IOCB_MBX
;
423 * Force update of the local copy of cmdGetInx
425 phba
->sli
.ring
[ringno
].local_getidx
426 = le32_to_cpu(pgp
->cmdGetInx
);
427 spin_lock_irq(phba
->host
->host_lock
);
428 lpfc_sli_resume_iocb(phba
, &phba
->sli
.ring
[ringno
]);
429 spin_unlock_irq(phba
->host
->host_lock
);
435 lpfc_sli_chk_mbx_command(uint8_t mbxCommand
)
439 switch (mbxCommand
) {
443 case MBX_RUN_BIU_DIAG
:
446 case MBX_CONFIG_LINK
:
447 case MBX_CONFIG_RING
:
449 case MBX_READ_CONFIG
:
450 case MBX_READ_RCONFIG
:
452 case MBX_READ_STATUS
:
456 case MBX_READ_LNK_STAT
:
458 case MBX_UNREG_LOGIN
:
461 case MBX_DUMP_MEMORY
:
462 case MBX_DUMP_CONTEXT
:
467 case MBX_DEL_LD_ENTRY
:
468 case MBX_RUN_PROGRAM
:
472 case MBX_CONFIG_FARP
:
474 case MBX_RUN_BIU_DIAG64
:
475 case MBX_CONFIG_PORT
:
476 case MBX_READ_SPARM64
:
478 case MBX_REG_LOGIN64
:
480 case MBX_FLASH_WR_ULA
:
482 case MBX_LOAD_EXP_ROM
:
492 lpfc_sli_wake_mbox_wait(struct lpfc_hba
* phba
, LPFC_MBOXQ_t
* pmboxq
)
494 wait_queue_head_t
*pdone_q
;
497 * If pdone_q is empty, the driver thread gave up waiting and
500 pdone_q
= (wait_queue_head_t
*) pmboxq
->context1
;
502 wake_up_interruptible(pdone_q
);
507 lpfc_sli_def_mbox_cmpl(struct lpfc_hba
* phba
, LPFC_MBOXQ_t
* pmb
)
509 struct lpfc_dmabuf
*mp
;
510 mp
= (struct lpfc_dmabuf
*) (pmb
->context1
);
512 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
515 mempool_free( pmb
, phba
->mbox_mem_pool
);
520 lpfc_sli_handle_mb_event(struct lpfc_hba
* phba
)
525 struct lpfc_sli
*psli
;
527 uint32_t process_next
;
530 /* We should only get here if we are in SLI2 mode */
531 if (!(phba
->sli
.sli_flag
& LPFC_SLI2_ACTIVE
)) {
535 phba
->sli
.slistat
.mbox_event
++;
537 /* Get a Mailbox buffer to setup mailbox commands for callback */
538 if ((pmb
= phba
->sli
.mbox_active
)) {
540 mbox
= (MAILBOX_t
*) phba
->sli
.MBhostaddr
;
542 /* First check out the status word */
543 lpfc_sli_pcimem_bcopy(mbox
, pmbox
, sizeof (uint32_t));
545 /* Sanity check to ensure the host owns the mailbox */
546 if (pmbox
->mbxOwner
!= OWN_HOST
) {
547 /* Lets try for a while */
548 for (i
= 0; i
< 10240; i
++) {
549 /* First copy command data */
550 lpfc_sli_pcimem_bcopy(mbox
, pmbox
,
552 if (pmbox
->mbxOwner
== OWN_HOST
)
555 /* Stray Mailbox Interrupt, mbxCommand <cmd> mbxStatus
557 lpfc_printf_log(phba
,
560 "%d:0304 Stray Mailbox Interrupt "
561 "mbxCommand x%x mbxStatus x%x\n",
566 spin_lock_irq(phba
->host
->host_lock
);
567 phba
->sli
.sli_flag
|= LPFC_SLI_MBOX_ACTIVE
;
568 spin_unlock_irq(phba
->host
->host_lock
);
573 del_timer_sync(&phba
->sli
.mbox_tmo
);
574 phba
->work_hba_events
&= ~WORKER_MBOX_TMO
;
577 * It is a fatal error if unknown mbox command completion.
579 if (lpfc_sli_chk_mbx_command(pmbox
->mbxCommand
) ==
582 /* Unknow mailbox command compl */
583 lpfc_printf_log(phba
,
586 "%d:0323 Unknown Mailbox command %x Cmpl\n",
589 phba
->hba_state
= LPFC_HBA_ERROR
;
590 phba
->work_hs
= HS_FFER3
;
591 lpfc_handle_eratt(phba
);
595 phba
->sli
.mbox_active
= NULL
;
596 if (pmbox
->mbxStatus
) {
597 phba
->sli
.slistat
.mbox_stat_err
++;
598 if (pmbox
->mbxStatus
== MBXERR_NO_RESOURCES
) {
599 /* Mbox cmd cmpl error - RETRYing */
600 lpfc_printf_log(phba
,
603 "%d:0305 Mbox cmd cmpl error - "
604 "RETRYing Data: x%x x%x x%x x%x\n",
608 pmbox
->un
.varWords
[0],
610 pmbox
->mbxStatus
= 0;
611 pmbox
->mbxOwner
= OWN_HOST
;
612 spin_lock_irq(phba
->host
->host_lock
);
613 phba
->sli
.sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
614 spin_unlock_irq(phba
->host
->host_lock
);
615 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_NOWAIT
);
616 if (rc
== MBX_SUCCESS
)
621 /* Mailbox cmd <cmd> Cmpl <cmpl> */
622 lpfc_printf_log(phba
,
625 "%d:0307 Mailbox cmd x%x Cmpl x%p "
626 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n",
630 *((uint32_t *) pmbox
),
631 pmbox
->un
.varWords
[0],
632 pmbox
->un
.varWords
[1],
633 pmbox
->un
.varWords
[2],
634 pmbox
->un
.varWords
[3],
635 pmbox
->un
.varWords
[4],
636 pmbox
->un
.varWords
[5],
637 pmbox
->un
.varWords
[6],
638 pmbox
->un
.varWords
[7]);
640 if (pmb
->mbox_cmpl
) {
641 lpfc_sli_pcimem_bcopy(mbox
, pmbox
, MAILBOX_CMD_SIZE
);
642 pmb
->mbox_cmpl(phba
,pmb
);
648 process_next
= 0; /* by default don't loop */
649 spin_lock_irq(phba
->host
->host_lock
);
650 phba
->sli
.sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
652 /* Process next mailbox command if there is one */
653 if ((pmb
= lpfc_mbox_get(phba
))) {
654 spin_unlock_irq(phba
->host
->host_lock
);
655 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_NOWAIT
);
656 if (rc
== MBX_NOT_FINISHED
) {
657 pmb
->mb
.mbxStatus
= MBX_NOT_FINISHED
;
658 pmb
->mbox_cmpl(phba
,pmb
);
660 continue; /* loop back */
663 spin_unlock_irq(phba
->host
->host_lock
);
664 /* Turn on IOCB processing */
665 for (i
= 0; i
< phba
->sli
.num_rings
; i
++) {
666 lpfc_sli_turn_on_ring(phba
, i
);
669 /* Free any lpfc_dmabuf's waiting for mbox cmd cmpls */
670 while (!list_empty(&phba
->freebufList
)) {
671 struct lpfc_dmabuf
*mp
;
674 list_remove_head((&phba
->freebufList
),
679 lpfc_mbuf_free(phba
, mp
->virt
,
686 } while (process_next
);
691 lpfc_sli_process_unsol_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
692 struct lpfc_iocbq
*saveq
)
700 irsp
= &(saveq
->iocb
);
701 if ((irsp
->ulpCommand
== CMD_RCV_ELS_REQ64_CX
)
702 || (irsp
->ulpCommand
== CMD_RCV_ELS_REQ_CX
)) {
707 (WORD5
*) & (saveq
->iocb
.un
.
709 Rctl
= w5p
->hcsw
.Rctl
;
710 Type
= w5p
->hcsw
.Type
;
712 /* Firmware Workaround */
713 if ((Rctl
== 0) && (pring
->ringno
== LPFC_ELS_RING
) &&
714 (irsp
->ulpCommand
== CMD_RCV_SEQUENCE64_CX
)) {
717 w5p
->hcsw
.Rctl
= Rctl
;
718 w5p
->hcsw
.Type
= Type
;
721 /* unSolicited Responses */
722 if (pring
->prt
[0].profile
) {
723 (pring
->prt
[0].lpfc_sli_rcv_unsol_event
) (phba
, pring
, saveq
);
726 /* We must search, based on rctl / type
727 for the right routine */
728 for (i
= 0; i
< pring
->num_mask
;
730 if ((pring
->prt
[i
].rctl
==
734 (pring
->prt
[i
].lpfc_sli_rcv_unsol_event
)
735 (phba
, pring
, saveq
);
742 /* Unexpected Rctl / Type received */
743 /* Ring <ringno> handler: unexpected
744 Rctl <Rctl> Type <Type> received */
745 lpfc_printf_log(phba
,
748 "%d:0313 Ring %d handler: unexpected Rctl x%x "
749 "Type x%x received \n",
758 static struct lpfc_iocbq
*
759 lpfc_sli_txcmpl_ring_search_slow(struct lpfc_sli_ring
* pring
,
760 struct lpfc_iocbq
* prspiocb
)
764 struct lpfc_iocbq
*cmd_iocb
;
765 struct lpfc_iocbq
*iocb
, *next_iocb
;
768 irsp
= &prspiocb
->iocb
;
769 iotag
= irsp
->ulpIoTag
;
772 /* Search through txcmpl from the begining */
773 list_for_each_entry_safe(iocb
, next_iocb
, &(pring
->txcmplq
), list
) {
775 if (iotag
== icmd
->ulpIoTag
) {
778 list_del(&iocb
->list
);
779 pring
->txcmplq_cnt
--;
787 static struct lpfc_iocbq
*
788 lpfc_sli_txcmpl_ring_iotag_lookup(struct lpfc_hba
* phba
,
789 struct lpfc_sli_ring
* pring
,
790 struct lpfc_iocbq
* prspiocb
)
793 struct lpfc_iocbq
*cmd_iocb
= NULL
;
796 if (unlikely(pring
->fast_lookup
== NULL
))
799 /* Use fast lookup based on iotag for completion */
800 irsp
= &prspiocb
->iocb
;
801 iotag
= irsp
->ulpIoTag
;
802 if (iotag
< pring
->fast_iotag
) {
803 cmd_iocb
= *(pring
->fast_lookup
+ iotag
);
804 *(pring
->fast_lookup
+ iotag
) = NULL
;
806 list_del(&cmd_iocb
->list
);
807 pring
->txcmplq_cnt
--;
811 * This is clearly an error. A ring that uses iotags
812 * should never have a interrupt for a completion that
813 * is not on the ring. Return NULL and log a error.
815 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
816 "%d:0327 Rsp ring %d error - command "
817 "completion for iotag x%x not found\n",
818 phba
->brd_no
, pring
->ringno
, iotag
);
824 * Rsp ring <ringno> get: iotag <iotag> greater then
825 * configured max <fast_iotag> wd0 <irsp>. This is an
826 * error. Just return NULL.
828 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
829 "%d:0317 Rsp ring %d get: iotag x%x greater then "
830 "configured max x%x wd0 x%x\n",
831 phba
->brd_no
, pring
->ringno
, iotag
, pring
->fast_iotag
,
832 *(((uint32_t *) irsp
) + 7));
837 lpfc_sli_process_sol_iocb(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
,
838 struct lpfc_iocbq
*saveq
)
840 struct lpfc_iocbq
* cmdiocbp
;
844 /* Based on the iotag field, get the cmd IOCB from the txcmplq */
845 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
846 cmdiocbp
= lpfc_sli_txcmpl_ring_search_slow(pring
, saveq
);
848 if (cmdiocbp
->iocb_cmpl
) {
850 * Post all ELS completions to the worker thread.
851 * All other are passed to the completion callback.
853 if (pring
->ringno
== LPFC_ELS_RING
) {
854 spin_unlock_irqrestore(phba
->host
->host_lock
,
856 (cmdiocbp
->iocb_cmpl
) (phba
, cmdiocbp
, saveq
);
857 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
860 if (cmdiocbp
->iocb_flag
& LPFC_IO_POLL
)
863 spin_unlock_irqrestore(phba
->host
->host_lock
,
865 (cmdiocbp
->iocb_cmpl
) (phba
, cmdiocbp
, saveq
);
866 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
869 list_add_tail(&cmdiocbp
->list
, &phba
->lpfc_iocb_list
);
873 * Unknown initiating command based on the response iotag.
874 * This could be the case on the ELS ring because of
877 if (pring
->ringno
!= LPFC_ELS_RING
) {
879 * Ring <ringno> handler: unexpected completion IoTag
882 lpfc_printf_log(phba
,
885 "%d:0322 Ring %d handler: unexpected "
886 "completion IoTag x%x Data: x%x x%x x%x x%x\n",
889 saveq
->iocb
.ulpIoTag
,
890 saveq
->iocb
.ulpStatus
,
891 saveq
->iocb
.un
.ulpWord
[4],
892 saveq
->iocb
.ulpCommand
,
893 saveq
->iocb
.ulpContext
);
896 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
901 * This routine presumes LPFC_FCP_RING handling and doesn't bother
902 * to check it explicitly.
905 lpfc_sli_handle_fast_ring_event(struct lpfc_hba
* phba
,
906 struct lpfc_sli_ring
* pring
, uint32_t mask
)
909 struct lpfc_iocbq
*cmdiocbq
= NULL
;
910 struct lpfc_iocbq rspiocbq
;
913 uint32_t portRspPut
, portRspMax
;
917 uint32_t rsp_cmpl
= 0;
918 void __iomem
*to_slim
;
920 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
921 pring
->stats
.iocb_event
++;
923 /* The driver assumes SLI-2 mode */
924 pgp
= (PGP
*) &((MAILBOX_t
*) phba
->sli
.MBhostaddr
)
925 ->us
.s2
.port
[pring
->ringno
];
928 * The next available response entry should never exceed the maximum
929 * entries. If it does, treat it as an adapter hardware error.
931 portRspMax
= pring
->numRiocb
;
932 portRspPut
= le32_to_cpu(pgp
->rspPutInx
);
933 if (unlikely(portRspPut
>= portRspMax
)) {
935 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
936 * rsp ring <portRspMax>
938 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
939 "%d:0312 Ring %d handler: portRspPut %d "
940 "is bigger then rsp ring %d\n",
941 phba
->brd_no
, pring
->ringno
, portRspPut
,
944 phba
->hba_state
= LPFC_HBA_ERROR
;
946 /* All error attention handlers are posted to worker thread */
947 phba
->work_ha
|= HA_ERATT
;
948 phba
->work_hs
= HS_FFER3
;
950 wake_up(phba
->work_wait
);
952 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
957 while (pring
->rspidx
!= portRspPut
) {
958 irsp
= (IOCB_t
*) IOCB_ENTRY(pring
->rspringaddr
, pring
->rspidx
);
959 type
= lpfc_sli_iocb_cmd_type(irsp
->ulpCommand
& CMD_IOCB_MASK
);
960 pring
->stats
.iocb_rsp
++;
963 if (unlikely(irsp
->ulpStatus
)) {
964 /* Rsp ring <ringno> error: IOCB */
965 lpfc_printf_log(phba
, KERN_WARNING
, LOG_SLI
,
966 "%d:0326 Rsp Ring %d error: IOCB Data: "
967 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
968 phba
->brd_no
, pring
->ringno
,
969 irsp
->un
.ulpWord
[0], irsp
->un
.ulpWord
[1],
970 irsp
->un
.ulpWord
[2], irsp
->un
.ulpWord
[3],
971 irsp
->un
.ulpWord
[4], irsp
->un
.ulpWord
[5],
972 *(((uint32_t *) irsp
) + 6),
973 *(((uint32_t *) irsp
) + 7));
977 case LPFC_ABORT_IOCB
:
980 * Idle exchange closed via ABTS from port. No iocb
981 * resources need to be recovered.
983 if (unlikely(irsp
->ulpCommand
== CMD_XRI_ABORTED_CX
)) {
984 printk(KERN_INFO
"%s: IOCB cmd 0x%x processed. "
985 "Skipping completion\n", __FUNCTION__
,
990 rspiocbq
.iocb
.un
.ulpWord
[4] = irsp
->un
.ulpWord
[4];
991 rspiocbq
.iocb
.ulpStatus
= irsp
->ulpStatus
;
992 rspiocbq
.iocb
.ulpContext
= irsp
->ulpContext
;
993 rspiocbq
.iocb
.ulpIoTag
= irsp
->ulpIoTag
;
994 cmdiocbq
= lpfc_sli_txcmpl_ring_iotag_lookup(phba
,
997 if ((cmdiocbq
) && (cmdiocbq
->iocb_cmpl
)) {
998 spin_unlock_irqrestore(
999 phba
->host
->host_lock
, iflag
);
1000 (cmdiocbq
->iocb_cmpl
)(phba
, cmdiocbq
,
1002 spin_lock_irqsave(phba
->host
->host_lock
,
1007 if (irsp
->ulpCommand
== CMD_ADAPTER_MSG
) {
1008 char adaptermsg
[LPFC_MAX_ADPTMSG
];
1009 memset(adaptermsg
, 0, LPFC_MAX_ADPTMSG
);
1010 memcpy(&adaptermsg
[0], (uint8_t *) irsp
,
1012 dev_warn(&((phba
->pcidev
)->dev
), "lpfc%d: %s",
1013 phba
->brd_no
, adaptermsg
);
1015 /* Unknown IOCB command */
1016 lpfc_printf_log(phba
, KERN_ERR
, LOG_SLI
,
1017 "%d:0321 Unknown IOCB command "
1018 "Data: x%x, x%x x%x x%x x%x\n",
1019 phba
->brd_no
, type
, irsp
->ulpCommand
,
1020 irsp
->ulpStatus
, irsp
->ulpIoTag
,
1027 * The response IOCB has been processed. Update the ring
1028 * pointer in SLIM. If the port response put pointer has not
1029 * been updated, sync the pgp->rspPutInx and fetch the new port
1030 * response put pointer.
1032 if (++pring
->rspidx
>= portRspMax
)
1035 to_slim
= phba
->MBslimaddr
+
1036 (SLIMOFF
+ (pring
->ringno
* 2) + 1) * 4;
1037 writeb(pring
->rspidx
, to_slim
);
1039 if (pring
->rspidx
== portRspPut
)
1040 portRspPut
= le32_to_cpu(pgp
->rspPutInx
);
1043 if ((rsp_cmpl
> 0) && (mask
& HA_R0RE_REQ
)) {
1044 pring
->stats
.iocb_rsp_full
++;
1045 status
= ((CA_R0ATT
| CA_R0RE_RSP
) << (pring
->ringno
* 4));
1046 writel(status
, phba
->CAregaddr
);
1047 readl(phba
->CAregaddr
);
1049 if ((mask
& HA_R0CE_RSP
) && (pring
->flag
& LPFC_CALL_RING_AVAILABLE
)) {
1050 pring
->flag
&= ~LPFC_CALL_RING_AVAILABLE
;
1051 pring
->stats
.iocb_cmd_empty
++;
1053 /* Force update of the local copy of cmdGetInx */
1054 pring
->local_getidx
= le32_to_cpu(pgp
->cmdGetInx
);
1055 lpfc_sli_resume_iocb(phba
, pring
);
1057 if ((pring
->lpfc_sli_cmd_available
))
1058 (pring
->lpfc_sli_cmd_available
) (phba
, pring
);
1062 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
1068 lpfc_sli_handle_slow_ring_event(struct lpfc_hba
* phba
,
1069 struct lpfc_sli_ring
* pring
, uint32_t mask
)
1072 IOCB_t
*irsp
= NULL
;
1073 struct lpfc_iocbq
*rspiocbp
= NULL
;
1074 struct lpfc_iocbq
*next_iocb
;
1075 struct lpfc_iocbq
*cmdiocbp
;
1076 struct lpfc_iocbq
*saveq
;
1077 struct list_head
*lpfc_iocb_list
= &phba
->lpfc_iocb_list
;
1081 uint8_t iocb_cmd_type
;
1082 lpfc_iocb_type type
;
1083 uint32_t status
, free_saveq
;
1084 uint32_t portRspPut
, portRspMax
;
1086 unsigned long iflag
;
1087 void __iomem
*to_slim
;
1089 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
1090 pring
->stats
.iocb_event
++;
1092 /* The driver assumes SLI-2 mode */
1093 mbox
= (MAILBOX_t
*) phba
->sli
.MBhostaddr
;
1094 pgp
= (PGP
*) & mbox
->us
.s2
.port
[pring
->ringno
];
1095 hgp
= (HGP
*) & mbox
->us
.s2
.host
[pring
->ringno
];
1098 * The next available response entry should never exceed the maximum
1099 * entries. If it does, treat it as an adapter hardware error.
1101 portRspMax
= pring
->numRiocb
;
1102 portRspPut
= le32_to_cpu(pgp
->rspPutInx
);
1103 if (portRspPut
>= portRspMax
) {
1105 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
1106 * rsp ring <portRspMax>
1108 lpfc_printf_log(phba
,
1111 "%d:0312 Ring %d handler: portRspPut %d "
1112 "is bigger then rsp ring %d\n",
1114 pring
->ringno
, portRspPut
, portRspMax
);
1116 phba
->hba_state
= LPFC_HBA_ERROR
;
1117 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
1119 phba
->work_hs
= HS_FFER3
;
1120 lpfc_handle_eratt(phba
);
1126 lpfc_iocb_list
= &phba
->lpfc_iocb_list
;
1127 while (pring
->rspidx
!= portRspPut
) {
1129 * Build a completion list and call the appropriate handler.
1130 * The process is to get the next available response iocb, get
1131 * a free iocb from the list, copy the response data into the
1132 * free iocb, insert to the continuation list, and update the
1133 * next response index to slim. This process makes response
1134 * iocb's in the ring available to DMA as fast as possible but
1135 * pays a penalty for a copy operation. Since the iocb is
1136 * only 32 bytes, this penalty is considered small relative to
1137 * the PCI reads for register values and a slim write. When
1138 * the ulpLe field is set, the entire Command has been
1141 entry
= IOCB_ENTRY(pring
->rspringaddr
, pring
->rspidx
);
1142 list_remove_head(lpfc_iocb_list
, rspiocbp
, struct lpfc_iocbq
,
1144 if (rspiocbp
== NULL
) {
1145 printk(KERN_ERR
"%s: out of buffers! Failing "
1146 "completion.\n", __FUNCTION__
);
1150 lpfc_sli_pcimem_bcopy(entry
, &rspiocbp
->iocb
, sizeof (IOCB_t
));
1151 irsp
= &rspiocbp
->iocb
;
1153 if (++pring
->rspidx
>= portRspMax
)
1156 to_slim
= phba
->MBslimaddr
+ (SLIMOFF
+ (pring
->ringno
* 2)
1158 writeb(pring
->rspidx
, to_slim
);
1160 if (list_empty(&(pring
->iocb_continueq
))) {
1161 list_add(&rspiocbp
->list
, &(pring
->iocb_continueq
));
1163 list_add_tail(&rspiocbp
->list
,
1164 &(pring
->iocb_continueq
));
1167 pring
->iocb_continueq_cnt
++;
1170 * By default, the driver expects to free all resources
1171 * associated with this iocb completion.
1174 saveq
= list_get_first(&pring
->iocb_continueq
,
1175 struct lpfc_iocbq
, list
);
1176 irsp
= &(saveq
->iocb
);
1177 list_del_init(&pring
->iocb_continueq
);
1178 pring
->iocb_continueq_cnt
= 0;
1180 pring
->stats
.iocb_rsp
++;
1182 if (irsp
->ulpStatus
) {
1183 /* Rsp ring <ringno> error: IOCB */
1184 lpfc_printf_log(phba
,
1187 "%d:0328 Rsp Ring %d error: IOCB Data: "
1188 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
1191 irsp
->un
.ulpWord
[0],
1192 irsp
->un
.ulpWord
[1],
1193 irsp
->un
.ulpWord
[2],
1194 irsp
->un
.ulpWord
[3],
1195 irsp
->un
.ulpWord
[4],
1196 irsp
->un
.ulpWord
[5],
1197 *(((uint32_t *) irsp
) + 6),
1198 *(((uint32_t *) irsp
) + 7));
1202 * Fetch the IOCB command type and call the correct
1203 * completion routine. Solicited and Unsolicited
1204 * IOCBs on the ELS ring get freed back to the
1205 * lpfc_iocb_list by the discovery kernel thread.
1207 iocb_cmd_type
= irsp
->ulpCommand
& CMD_IOCB_MASK
;
1208 type
= lpfc_sli_iocb_cmd_type(iocb_cmd_type
);
1209 if (type
== LPFC_SOL_IOCB
) {
1210 spin_unlock_irqrestore(phba
->host
->host_lock
,
1212 rc
= lpfc_sli_process_sol_iocb(phba
, pring
,
1214 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
1215 } else if (type
== LPFC_UNSOL_IOCB
) {
1216 spin_unlock_irqrestore(phba
->host
->host_lock
,
1218 rc
= lpfc_sli_process_unsol_iocb(phba
, pring
,
1220 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
1221 } else if (type
== LPFC_ABORT_IOCB
) {
1222 if ((irsp
->ulpCommand
!= CMD_XRI_ABORTED_CX
) &&
1224 lpfc_sli_txcmpl_ring_search_slow(pring
,
1226 /* Call the specified completion
1228 if (cmdiocbp
->iocb_cmpl
) {
1229 spin_unlock_irqrestore(
1230 phba
->host
->host_lock
,
1232 (cmdiocbp
->iocb_cmpl
) (phba
,
1235 phba
->host
->host_lock
,
1238 list_add_tail(&cmdiocbp
->list
,
1242 } else if (type
== LPFC_UNKNOWN_IOCB
) {
1243 if (irsp
->ulpCommand
== CMD_ADAPTER_MSG
) {
1245 char adaptermsg
[LPFC_MAX_ADPTMSG
];
1247 memset(adaptermsg
, 0,
1249 memcpy(&adaptermsg
[0], (uint8_t *) irsp
,
1251 dev_warn(&((phba
->pcidev
)->dev
),
1253 phba
->brd_no
, adaptermsg
);
1255 /* Unknown IOCB command */
1256 lpfc_printf_log(phba
,
1259 "%d:0321 Unknown IOCB command "
1260 "Data: x%x x%x x%x x%x\n",
1270 if (!list_empty(&saveq
->list
)) {
1271 list_for_each_entry_safe(rspiocbp
,
1275 list_add_tail(&rspiocbp
->list
,
1280 list_add_tail(&saveq
->list
, lpfc_iocb_list
);
1285 * If the port response put pointer has not been updated, sync
1286 * the pgp->rspPutInx in the MAILBOX_tand fetch the new port
1287 * response put pointer.
1289 if (pring
->rspidx
== portRspPut
) {
1290 portRspPut
= le32_to_cpu(pgp
->rspPutInx
);
1292 } /* while (pring->rspidx != portRspPut) */
1294 if ((rspiocbp
!= 0) && (mask
& HA_R0RE_REQ
)) {
1295 /* At least one response entry has been freed */
1296 pring
->stats
.iocb_rsp_full
++;
1297 /* SET RxRE_RSP in Chip Att register */
1298 status
= ((CA_R0ATT
| CA_R0RE_RSP
) << (pring
->ringno
* 4));
1299 writel(status
, phba
->CAregaddr
);
1300 readl(phba
->CAregaddr
); /* flush */
1302 if ((mask
& HA_R0CE_RSP
) && (pring
->flag
& LPFC_CALL_RING_AVAILABLE
)) {
1303 pring
->flag
&= ~LPFC_CALL_RING_AVAILABLE
;
1304 pring
->stats
.iocb_cmd_empty
++;
1306 /* Force update of the local copy of cmdGetInx */
1307 pring
->local_getidx
= le32_to_cpu(pgp
->cmdGetInx
);
1308 lpfc_sli_resume_iocb(phba
, pring
);
1310 if ((pring
->lpfc_sli_cmd_available
))
1311 (pring
->lpfc_sli_cmd_available
) (phba
, pring
);
1315 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
1320 lpfc_sli_abort_iocb_ring(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
)
1322 struct lpfc_iocbq
*iocb
, *next_iocb
;
1323 IOCB_t
*icmd
= NULL
, *cmd
= NULL
;
1329 /* Error everything on txq and txcmplq
1332 spin_lock_irq(phba
->host
->host_lock
);
1333 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
1334 list_del_init(&iocb
->list
);
1335 if (iocb
->iocb_cmpl
) {
1337 icmd
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
1338 icmd
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
1339 spin_unlock_irq(phba
->host
->host_lock
);
1340 (iocb
->iocb_cmpl
) (phba
, iocb
, iocb
);
1341 spin_lock_irq(phba
->host
->host_lock
);
1343 list_add_tail(&iocb
->list
, &phba
->lpfc_iocb_list
);
1347 INIT_LIST_HEAD(&(pring
->txq
));
1349 /* Next issue ABTS for everything on the txcmplq */
1350 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
1354 * Imediate abort of IOCB, clear fast_lookup entry,
1355 * if any, deque and call compl
1357 iotag
= cmd
->ulpIoTag
;
1358 if (iotag
&& pring
->fast_lookup
&&
1359 (iotag
< pring
->fast_iotag
))
1360 pring
->fast_lookup
[iotag
] = NULL
;
1362 list_del_init(&iocb
->list
);
1363 pring
->txcmplq_cnt
--;
1365 if (iocb
->iocb_cmpl
) {
1366 cmd
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
1367 cmd
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
1368 spin_unlock_irq(phba
->host
->host_lock
);
1369 (iocb
->iocb_cmpl
) (phba
, iocb
, iocb
);
1370 spin_lock_irq(phba
->host
->host_lock
);
1372 list_add_tail(&iocb
->list
, &phba
->lpfc_iocb_list
);
1376 INIT_LIST_HEAD(&pring
->txcmplq
);
1377 pring
->txcmplq_cnt
= 0;
1378 spin_unlock_irq(phba
->host
->host_lock
);
1383 /******************************************************************************
1384 * lpfc_sli_send_reset
1386 * Note: After returning from this function, the HBA cannot be accessed for
1387 * 1 ms. Since we do not wish to delay in interrupt context, it is the
1388 * responsibility of the caller to perform the mdelay(1) and flush via readl().
1389 ******************************************************************************/
1391 lpfc_sli_send_reset(struct lpfc_hba
* phba
, uint16_t skip_post
)
1394 volatile uint32_t word0
;
1395 void __iomem
*to_slim
;
1396 unsigned long flags
= 0;
1398 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
1400 /* A board reset must use REAL SLIM. */
1401 phba
->sli
.sli_flag
&= ~LPFC_SLI2_ACTIVE
;
1404 swpmb
= (MAILBOX_t
*) & word0
;
1405 swpmb
->mbxCommand
= MBX_RESTART
;
1408 to_slim
= phba
->MBslimaddr
;
1409 writel(*(uint32_t *) swpmb
, to_slim
);
1410 readl(to_slim
); /* flush */
1412 /* Only skip post after fc_ffinit is completed */
1414 word0
= 1; /* This is really setting up word1 */
1416 word0
= 0; /* This is really setting up word1 */
1418 to_slim
= phba
->MBslimaddr
+ sizeof (uint32_t);
1419 writel(*(uint32_t *) swpmb
, to_slim
);
1420 readl(to_slim
); /* flush */
1422 /* Turn off parity checking and serr during the physical reset */
1423 pci_read_config_word(phba
->pcidev
, PCI_COMMAND
, &phba
->pci_cfg_value
);
1424 pci_write_config_word(phba
->pcidev
, PCI_COMMAND
,
1425 (phba
->pci_cfg_value
&
1426 ~(PCI_COMMAND_PARITY
| PCI_COMMAND_SERR
)));
1428 writel(HC_INITFF
, phba
->HCregaddr
);
1430 phba
->hba_state
= LPFC_INIT_START
;
1431 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
1437 lpfc_sli_brdreset(struct lpfc_hba
* phba
, uint16_t skip_post
)
1439 struct lpfc_sli_ring
*pring
;
1441 struct lpfc_dmabuf
*mp
, *next_mp
;
1442 unsigned long flags
= 0;
1444 lpfc_sli_send_reset(phba
, skip_post
);
1447 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
1448 /* Risk the write on flush case ie no delay after the readl */
1449 readl(phba
->HCregaddr
); /* flush */
1450 /* Now toggle INITFF bit set by lpfc_sli_send_reset */
1451 writel(0, phba
->HCregaddr
);
1452 readl(phba
->HCregaddr
); /* flush */
1454 /* Restore PCI cmd register */
1455 pci_write_config_word(phba
->pcidev
, PCI_COMMAND
, phba
->pci_cfg_value
);
1457 /* perform board reset */
1458 phba
->fc_eventTag
= 0;
1460 phba
->fc_prevDID
= Mask_DID
;
1463 lpfc_printf_log(phba
,
1466 "%d:0325 Reset HBA Data: x%x x%x x%x\n",
1472 /* Initialize relevant SLI info */
1473 for (i
= 0; i
< phba
->sli
.num_rings
; i
++) {
1474 pring
= &phba
->sli
.ring
[i
];
1477 pring
->next_cmdidx
= 0;
1478 pring
->local_getidx
= 0;
1480 pring
->missbufcnt
= 0;
1482 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
1490 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
1491 /* Cleanup preposted buffers on the ELS ring */
1492 pring
= &phba
->sli
.ring
[LPFC_ELS_RING
];
1493 list_for_each_entry_safe(mp
, next_mp
, &pring
->postbufq
, list
) {
1494 list_del(&mp
->list
);
1495 pring
->postbufq_cnt
--;
1496 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1499 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
1501 for (i
= 0; i
< phba
->sli
.num_rings
; i
++)
1502 lpfc_sli_abort_iocb_ring(phba
, &phba
->sli
.ring
[i
]);
1508 lpfc_sli_chipset_init(struct lpfc_hba
*phba
)
1510 uint32_t status
, i
= 0;
1512 /* Read the HBA Host Status Register */
1513 status
= readl(phba
->HSregaddr
);
1515 /* Check status register to see what current state is */
1517 while ((status
& (HS_FFRDY
| HS_MBRDY
)) != (HS_FFRDY
| HS_MBRDY
)) {
1519 /* Check every 100ms for 5 retries, then every 500ms for 5, then
1520 * every 2.5 sec for 5, then reset board and every 2.5 sec for
1524 /* Adapter failed to init, timeout, status reg
1526 lpfc_printf_log(phba
,
1529 "%d:0436 Adapter failed to init, "
1530 "timeout, status reg x%x\n",
1533 phba
->hba_state
= LPFC_HBA_ERROR
;
1537 /* Check to see if any errors occurred during init */
1538 if (status
& HS_FFERM
) {
1539 /* ERROR: During chipset initialization */
1540 /* Adapter failed to init, chipset, status reg
1542 lpfc_printf_log(phba
,
1545 "%d:0437 Adapter failed to init, "
1546 "chipset, status reg x%x\n",
1549 phba
->hba_state
= LPFC_HBA_ERROR
;
1555 } else if (i
<= 10) {
1562 lpfc_sli_brdreset(phba
, 0);
1564 /* Read the HBA Host Status Register */
1565 status
= readl(phba
->HSregaddr
);
1568 /* Check to see if any errors occurred during init */
1569 if (status
& HS_FFERM
) {
1570 /* ERROR: During chipset initialization */
1571 /* Adapter failed to init, chipset, status reg <status> */
1572 lpfc_printf_log(phba
,
1575 "%d:0438 Adapter failed to init, chipset, "
1579 phba
->hba_state
= LPFC_HBA_ERROR
;
1583 /* Clear all interrupt enable conditions */
1584 writel(0, phba
->HCregaddr
);
1585 readl(phba
->HCregaddr
); /* flush */
1587 /* setup host attn register */
1588 writel(0xffffffff, phba
->HAregaddr
);
1589 readl(phba
->HAregaddr
); /* flush */
1594 lpfc_sli_hba_setup(struct lpfc_hba
* phba
)
1597 uint32_t resetcount
= 0, rc
= 0, done
= 0;
1599 pmb
= (LPFC_MBOXQ_t
*) mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1601 phba
->hba_state
= LPFC_HBA_ERROR
;
1605 while (resetcount
< 2 && !done
) {
1606 phba
->hba_state
= 0;
1607 lpfc_sli_brdreset(phba
, 0);
1609 rc
= lpfc_sli_chipset_init(phba
);
1615 /* Call pre CONFIG_PORT mailbox command initialization. A value of 0
1616 * means the call was successful. Any other nonzero value is a failure,
1617 * but if ERESTART is returned, the driver may reset the HBA and try
1620 rc
= lpfc_config_port_prep(phba
);
1621 if (rc
== -ERESTART
) {
1622 phba
->hba_state
= 0;
1628 phba
->hba_state
= LPFC_INIT_MBX_CMDS
;
1629 lpfc_config_port(phba
, pmb
);
1630 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_POLL
);
1631 if (rc
== MBX_SUCCESS
)
1634 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1635 "%d:0442 Adapter failed to init, mbxCmd x%x "
1636 "CONFIG_PORT, mbxStatus x%x Data: x%x\n",
1637 phba
->brd_no
, pmb
->mb
.mbxCommand
,
1638 pmb
->mb
.mbxStatus
, 0);
1639 phba
->sli
.sli_flag
&= ~LPFC_SLI2_ACTIVE
;
1643 goto lpfc_sli_hba_setup_error
;
1645 rc
= lpfc_sli_ring_map(phba
, pmb
);
1648 goto lpfc_sli_hba_setup_error
;
1650 phba
->sli
.sli_flag
|= LPFC_PROCESS_LA
;
1652 rc
= lpfc_config_port_post(phba
);
1654 goto lpfc_sli_hba_setup_error
;
1656 goto lpfc_sli_hba_setup_exit
;
1657 lpfc_sli_hba_setup_error
:
1658 phba
->hba_state
= LPFC_HBA_ERROR
;
1659 lpfc_sli_hba_setup_exit
:
1660 mempool_free(pmb
, phba
->mbox_mem_pool
);
1665 lpfc_mbox_abort(struct lpfc_hba
* phba
)
1667 LPFC_MBOXQ_t
*pmbox
;
1670 if (phba
->sli
.mbox_active
) {
1671 del_timer_sync(&phba
->sli
.mbox_tmo
);
1672 phba
->work_hba_events
&= ~WORKER_MBOX_TMO
;
1673 pmbox
= phba
->sli
.mbox_active
;
1675 phba
->sli
.mbox_active
= NULL
;
1676 if (pmbox
->mbox_cmpl
) {
1677 mb
->mbxStatus
= MBX_NOT_FINISHED
;
1678 (pmbox
->mbox_cmpl
) (phba
, pmbox
);
1680 phba
->sli
.sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
1683 /* Abort all the non active mailbox commands. */
1684 spin_lock_irq(phba
->host
->host_lock
);
1685 pmbox
= lpfc_mbox_get(phba
);
1688 if (pmbox
->mbox_cmpl
) {
1689 mb
->mbxStatus
= MBX_NOT_FINISHED
;
1690 spin_unlock_irq(phba
->host
->host_lock
);
1691 (pmbox
->mbox_cmpl
) (phba
, pmbox
);
1692 spin_lock_irq(phba
->host
->host_lock
);
1694 pmbox
= lpfc_mbox_get(phba
);
1696 spin_unlock_irq(phba
->host
->host_lock
);
1700 /*! lpfc_mbox_timeout
1704 * \param hba Pointer to per struct lpfc_hba structure
1705 * \param l1 Pointer to the driver's mailbox queue.
1711 * This routine handles mailbox timeout events at timer interrupt context.
1714 lpfc_mbox_timeout(unsigned long ptr
)
1716 struct lpfc_hba
*phba
;
1717 unsigned long iflag
;
1719 phba
= (struct lpfc_hba
*)ptr
;
1720 spin_lock_irqsave(phba
->host
->host_lock
, iflag
);
1721 if (!(phba
->work_hba_events
& WORKER_MBOX_TMO
)) {
1722 phba
->work_hba_events
|= WORKER_MBOX_TMO
;
1723 if (phba
->work_wait
)
1724 wake_up(phba
->work_wait
);
1726 spin_unlock_irqrestore(phba
->host
->host_lock
, iflag
);
1730 lpfc_mbox_timeout_handler(struct lpfc_hba
*phba
)
1732 LPFC_MBOXQ_t
*pmbox
;
1735 spin_lock_irq(phba
->host
->host_lock
);
1736 if (!(phba
->work_hba_events
& WORKER_MBOX_TMO
)) {
1737 spin_unlock_irq(phba
->host
->host_lock
);
1741 pmbox
= phba
->sli
.mbox_active
;
1744 /* Mbox cmd <mbxCommand> timeout */
1745 lpfc_printf_log(phba
,
1748 "%d:0310 Mailbox command x%x timeout Data: x%x x%x x%p\n",
1753 phba
->sli
.mbox_active
);
1755 if (phba
->sli
.mbox_active
== pmbox
) {
1756 phba
->sli
.mbox_active
= NULL
;
1757 if (pmbox
->mbox_cmpl
) {
1758 mb
->mbxStatus
= MBX_NOT_FINISHED
;
1759 spin_unlock_irq(phba
->host
->host_lock
);
1760 (pmbox
->mbox_cmpl
) (phba
, pmbox
);
1761 spin_lock_irq(phba
->host
->host_lock
);
1763 phba
->sli
.sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
1766 spin_unlock_irq(phba
->host
->host_lock
);
1767 lpfc_mbox_abort(phba
);
1772 lpfc_sli_issue_mbox(struct lpfc_hba
* phba
, LPFC_MBOXQ_t
* pmbox
, uint32_t flag
)
1776 struct lpfc_sli
*psli
;
1777 uint32_t status
, evtctr
;
1780 unsigned long drvr_flag
= 0;
1781 volatile uint32_t word0
, ldata
;
1782 void __iomem
*to_slim
;
1786 spin_lock_irqsave(phba
->host
->host_lock
, drvr_flag
);
1790 status
= MBX_SUCCESS
;
1792 if (psli
->sli_flag
& LPFC_SLI_MBOX_ACTIVE
) {
1793 /* Polling for a mbox command when another one is already active
1794 * is not allowed in SLI. Also, the driver must have established
1795 * SLI2 mode to queue and process multiple mbox commands.
1798 if (flag
& MBX_POLL
) {
1799 spin_unlock_irqrestore(phba
->host
->host_lock
,
1802 /* Mbox command <mbxCommand> cannot issue */
1803 LOG_MBOX_CANNOT_ISSUE_DATA( phba
, mb
, psli
, flag
)
1804 return (MBX_NOT_FINISHED
);
1807 if (!(psli
->sli_flag
& LPFC_SLI2_ACTIVE
)) {
1808 spin_unlock_irqrestore(phba
->host
->host_lock
,
1810 /* Mbox command <mbxCommand> cannot issue */
1811 LOG_MBOX_CANNOT_ISSUE_DATA( phba
, mb
, psli
, flag
)
1812 return (MBX_NOT_FINISHED
);
1815 /* Handle STOP IOCB processing flag. This is only meaningful
1816 * if we are not polling for mbox completion.
1818 if (flag
& MBX_STOP_IOCB
) {
1819 flag
&= ~MBX_STOP_IOCB
;
1820 /* Now flag each ring */
1821 for (i
= 0; i
< psli
->num_rings
; i
++) {
1822 /* If the ring is active, flag it */
1823 if (psli
->ring
[i
].cmdringaddr
) {
1824 psli
->ring
[i
].flag
|=
1830 /* Another mailbox command is still being processed, queue this
1831 * command to be processed later.
1833 lpfc_mbox_put(phba
, pmbox
);
1835 /* Mbox cmd issue - BUSY */
1836 lpfc_printf_log(phba
,
1839 "%d:0308 Mbox cmd issue - BUSY Data: x%x x%x x%x x%x\n",
1846 psli
->slistat
.mbox_busy
++;
1847 spin_unlock_irqrestore(phba
->host
->host_lock
,
1853 /* Handle STOP IOCB processing flag. This is only meaningful
1854 * if we are not polling for mbox completion.
1856 if (flag
& MBX_STOP_IOCB
) {
1857 flag
&= ~MBX_STOP_IOCB
;
1858 if (flag
== MBX_NOWAIT
) {
1859 /* Now flag each ring */
1860 for (i
= 0; i
< psli
->num_rings
; i
++) {
1861 /* If the ring is active, flag it */
1862 if (psli
->ring
[i
].cmdringaddr
) {
1863 psli
->ring
[i
].flag
|=
1870 psli
->sli_flag
|= LPFC_SLI_MBOX_ACTIVE
;
1872 /* If we are not polling, we MUST be in SLI2 mode */
1873 if (flag
!= MBX_POLL
) {
1874 if (!(psli
->sli_flag
& LPFC_SLI2_ACTIVE
)) {
1875 psli
->sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
1876 spin_unlock_irqrestore(phba
->host
->host_lock
,
1878 /* Mbox command <mbxCommand> cannot issue */
1879 LOG_MBOX_CANNOT_ISSUE_DATA( phba
, mb
, psli
, flag
);
1880 return (MBX_NOT_FINISHED
);
1882 /* timeout active mbox command */
1883 mod_timer(&psli
->mbox_tmo
, jiffies
+ HZ
* LPFC_MBOX_TMO
);
1886 /* Mailbox cmd <cmd> issue */
1887 lpfc_printf_log(phba
,
1890 "%d:0309 Mailbox cmd x%x issue Data: x%x x%x x%x\n",
1897 psli
->slistat
.mbox_cmd
++;
1898 evtctr
= psli
->slistat
.mbox_event
;
1900 /* next set own bit for the adapter and copy over command word */
1901 mb
->mbxOwner
= OWN_CHIP
;
1903 if (psli
->sli_flag
& LPFC_SLI2_ACTIVE
) {
1905 /* First copy command data to host SLIM area */
1906 mbox
= (MAILBOX_t
*) psli
->MBhostaddr
;
1907 lpfc_sli_pcimem_bcopy(mb
, mbox
, MAILBOX_CMD_SIZE
);
1909 if (mb
->mbxCommand
== MBX_CONFIG_PORT
) {
1910 /* copy command data into host mbox for cmpl */
1911 mbox
= (MAILBOX_t
*) psli
->MBhostaddr
;
1912 lpfc_sli_pcimem_bcopy(mb
, mbox
, MAILBOX_CMD_SIZE
);
1915 /* First copy mbox command data to HBA SLIM, skip past first
1917 to_slim
= phba
->MBslimaddr
+ sizeof (uint32_t);
1918 lpfc_memcpy_to_slim(to_slim
, &mb
->un
.varWords
[0],
1919 MAILBOX_CMD_SIZE
- sizeof (uint32_t));
1921 /* Next copy over first word, with mbxOwner set */
1922 ldata
= *((volatile uint32_t *)mb
);
1923 to_slim
= phba
->MBslimaddr
;
1924 writel(ldata
, to_slim
);
1925 readl(to_slim
); /* flush */
1927 if (mb
->mbxCommand
== MBX_CONFIG_PORT
) {
1928 /* switch over to host mailbox */
1929 psli
->sli_flag
|= LPFC_SLI2_ACTIVE
;
1934 /* interrupt board to doit right away */
1935 writel(CA_MBATT
, phba
->CAregaddr
);
1936 readl(phba
->CAregaddr
); /* flush */
1940 /* Don't wait for it to finish, just return */
1941 psli
->mbox_active
= pmbox
;
1946 psli
->mbox_active
= NULL
;
1947 if (psli
->sli_flag
& LPFC_SLI2_ACTIVE
) {
1948 /* First read mbox status word */
1949 mbox
= (MAILBOX_t
*) psli
->MBhostaddr
;
1950 word0
= *((volatile uint32_t *)mbox
);
1951 word0
= le32_to_cpu(word0
);
1953 /* First read mbox status word */
1954 word0
= readl(phba
->MBslimaddr
);
1957 /* Read the HBA Host Attention Register */
1958 ha_copy
= readl(phba
->HAregaddr
);
1960 /* Wait for command to complete */
1961 while (((word0
& OWN_CHIP
) == OWN_CHIP
)
1962 || !(ha_copy
& HA_MBATT
)) {
1964 psli
->sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
1965 spin_unlock_irqrestore(phba
->host
->host_lock
,
1967 return (MBX_NOT_FINISHED
);
1970 /* Check if we took a mbox interrupt while we were
1972 if (((word0
& OWN_CHIP
) != OWN_CHIP
)
1973 && (evtctr
!= psli
->slistat
.mbox_event
))
1976 spin_unlock_irqrestore(phba
->host
->host_lock
,
1979 /* Can be in interrupt context, do not sleep */
1980 /* (or might be called with interrupts disabled) */
1983 spin_lock_irqsave(phba
->host
->host_lock
, drvr_flag
);
1985 if (psli
->sli_flag
& LPFC_SLI2_ACTIVE
) {
1986 /* First copy command data */
1987 mbox
= (MAILBOX_t
*) psli
->MBhostaddr
;
1988 word0
= *((volatile uint32_t *)mbox
);
1989 word0
= le32_to_cpu(word0
);
1990 if (mb
->mbxCommand
== MBX_CONFIG_PORT
) {
1992 volatile uint32_t slimword0
;
1993 /* Check real SLIM for any errors */
1994 slimword0
= readl(phba
->MBslimaddr
);
1995 slimmb
= (MAILBOX_t
*) & slimword0
;
1996 if (((slimword0
& OWN_CHIP
) != OWN_CHIP
)
1997 && slimmb
->mbxStatus
) {
2004 /* First copy command data */
2005 word0
= readl(phba
->MBslimaddr
);
2007 /* Read the HBA Host Attention Register */
2008 ha_copy
= readl(phba
->HAregaddr
);
2011 if (psli
->sli_flag
& LPFC_SLI2_ACTIVE
) {
2012 /* First copy command data */
2013 mbox
= (MAILBOX_t
*) psli
->MBhostaddr
;
2014 /* copy results back to user */
2015 lpfc_sli_pcimem_bcopy(mbox
, mb
, MAILBOX_CMD_SIZE
);
2017 /* First copy command data */
2018 lpfc_memcpy_from_slim(mb
, phba
->MBslimaddr
,
2020 if ((mb
->mbxCommand
== MBX_DUMP_MEMORY
) &&
2022 lpfc_memcpy_from_slim((void *)pmbox
->context2
,
2023 phba
->MBslimaddr
+ DMP_RSP_OFFSET
,
2024 mb
->un
.varDmp
.word_cnt
);
2028 writel(HA_MBATT
, phba
->HAregaddr
);
2029 readl(phba
->HAregaddr
); /* flush */
2031 psli
->sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
2032 status
= mb
->mbxStatus
;
2035 spin_unlock_irqrestore(phba
->host
->host_lock
, drvr_flag
);
2040 lpfc_sli_ringtx_put(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
,
2041 struct lpfc_iocbq
* piocb
)
2043 /* Insert the caller's iocb in the txq tail for later processing. */
2044 list_add_tail(&piocb
->list
, &pring
->txq
);
2049 static struct lpfc_iocbq
*
2050 lpfc_sli_next_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
2051 struct lpfc_iocbq
** piocb
)
2053 struct lpfc_iocbq
* nextiocb
;
2055 nextiocb
= lpfc_sli_ringtx_get(phba
, pring
);
2065 lpfc_sli_issue_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
2066 struct lpfc_iocbq
*piocb
, uint32_t flag
)
2068 struct lpfc_iocbq
*nextiocb
;
2072 * We should never get an IOCB if we are in a < LINK_DOWN state
2074 if (unlikely(phba
->hba_state
< LPFC_LINK_DOWN
))
2078 * Check to see if we are blocking IOCB processing because of a
2079 * outstanding mbox command.
2081 if (unlikely(pring
->flag
& LPFC_STOP_IOCB_MBX
))
2084 if (unlikely(phba
->hba_state
== LPFC_LINK_DOWN
)) {
2086 * Only CREATE_XRI, CLOSE_XRI, ABORT_XRI, and QUE_RING_BUF
2087 * can be issued if the link is not up.
2089 switch (piocb
->iocb
.ulpCommand
) {
2090 case CMD_QUE_RING_BUF_CN
:
2091 case CMD_QUE_RING_BUF64_CN
:
2092 case CMD_CLOSE_XRI_CN
:
2093 case CMD_ABORT_XRI_CN
:
2095 * For IOCBs, like QUE_RING_BUF, that have no rsp ring
2096 * completion, iocb_cmpl MUST be 0.
2098 if (piocb
->iocb_cmpl
)
2099 piocb
->iocb_cmpl
= NULL
;
2101 case CMD_CREATE_XRI_CR
:
2108 * For FCP commands, we must be in a state where we can process link
2111 } else if (unlikely(pring
->ringno
== phba
->sli
.fcp_ring
&&
2112 !(phba
->sli
.sli_flag
& LPFC_PROCESS_LA
)))
2116 * Check to see if this is a high priority command.
2117 * If so bypass tx queue processing.
2119 if (unlikely((flag
& SLI_IOCB_HIGH_PRIORITY
) &&
2120 (iocb
= lpfc_sli_next_iocb_slot(phba
, pring
)))) {
2121 lpfc_sli_submit_iocb(phba
, pring
, iocb
, piocb
);
2125 while ((iocb
= lpfc_sli_next_iocb_slot(phba
, pring
)) &&
2126 (nextiocb
= lpfc_sli_next_iocb(phba
, pring
, &piocb
)))
2127 lpfc_sli_submit_iocb(phba
, pring
, iocb
, nextiocb
);
2130 lpfc_sli_update_ring(phba
, pring
);
2132 lpfc_sli_update_full_ring(phba
, pring
);
2135 return IOCB_SUCCESS
;
2140 pring
->stats
.iocb_cmd_delay
++;
2144 if (!(flag
& SLI_IOCB_RET_IOCB
)) {
2145 lpfc_sli_ringtx_put(phba
, pring
, piocb
);
2146 return IOCB_SUCCESS
;
2153 lpfc_sli_setup(struct lpfc_hba
*phba
)
2156 struct lpfc_sli
*psli
= &phba
->sli
;
2157 struct lpfc_sli_ring
*pring
;
2159 psli
->num_rings
= MAX_CONFIGURED_RINGS
;
2161 psli
->fcp_ring
= LPFC_FCP_RING
;
2162 psli
->next_ring
= LPFC_FCP_NEXT_RING
;
2163 psli
->ip_ring
= LPFC_IP_RING
;
2165 for (i
= 0; i
< psli
->num_rings
; i
++) {
2166 pring
= &psli
->ring
[i
];
2168 case LPFC_FCP_RING
: /* ring 0 - FCP */
2169 /* numCiocb and numRiocb are used in config_port */
2170 pring
->numCiocb
= SLI2_IOCB_CMD_R0_ENTRIES
;
2171 pring
->numRiocb
= SLI2_IOCB_RSP_R0_ENTRIES
;
2172 pring
->numCiocb
+= SLI2_IOCB_CMD_R1XTRA_ENTRIES
;
2173 pring
->numRiocb
+= SLI2_IOCB_RSP_R1XTRA_ENTRIES
;
2174 pring
->numCiocb
+= SLI2_IOCB_CMD_R3XTRA_ENTRIES
;
2175 pring
->numRiocb
+= SLI2_IOCB_RSP_R3XTRA_ENTRIES
;
2176 pring
->iotag_ctr
= 0;
2178 (phba
->cfg_hba_queue_depth
* 2);
2179 pring
->fast_iotag
= pring
->iotag_max
;
2180 pring
->num_mask
= 0;
2182 case LPFC_IP_RING
: /* ring 1 - IP */
2183 /* numCiocb and numRiocb are used in config_port */
2184 pring
->numCiocb
= SLI2_IOCB_CMD_R1_ENTRIES
;
2185 pring
->numRiocb
= SLI2_IOCB_RSP_R1_ENTRIES
;
2186 pring
->num_mask
= 0;
2188 case LPFC_ELS_RING
: /* ring 2 - ELS / CT */
2189 /* numCiocb and numRiocb are used in config_port */
2190 pring
->numCiocb
= SLI2_IOCB_CMD_R2_ENTRIES
;
2191 pring
->numRiocb
= SLI2_IOCB_RSP_R2_ENTRIES
;
2192 pring
->fast_iotag
= 0;
2193 pring
->iotag_ctr
= 0;
2194 pring
->iotag_max
= 4096;
2195 pring
->num_mask
= 4;
2196 pring
->prt
[0].profile
= 0; /* Mask 0 */
2197 pring
->prt
[0].rctl
= FC_ELS_REQ
;
2198 pring
->prt
[0].type
= FC_ELS_DATA
;
2199 pring
->prt
[0].lpfc_sli_rcv_unsol_event
=
2200 lpfc_els_unsol_event
;
2201 pring
->prt
[1].profile
= 0; /* Mask 1 */
2202 pring
->prt
[1].rctl
= FC_ELS_RSP
;
2203 pring
->prt
[1].type
= FC_ELS_DATA
;
2204 pring
->prt
[1].lpfc_sli_rcv_unsol_event
=
2205 lpfc_els_unsol_event
;
2206 pring
->prt
[2].profile
= 0; /* Mask 2 */
2207 /* NameServer Inquiry */
2208 pring
->prt
[2].rctl
= FC_UNSOL_CTL
;
2210 pring
->prt
[2].type
= FC_COMMON_TRANSPORT_ULP
;
2211 pring
->prt
[2].lpfc_sli_rcv_unsol_event
=
2212 lpfc_ct_unsol_event
;
2213 pring
->prt
[3].profile
= 0; /* Mask 3 */
2214 /* NameServer response */
2215 pring
->prt
[3].rctl
= FC_SOL_CTL
;
2217 pring
->prt
[3].type
= FC_COMMON_TRANSPORT_ULP
;
2218 pring
->prt
[3].lpfc_sli_rcv_unsol_event
=
2219 lpfc_ct_unsol_event
;
2222 totiocb
+= (pring
->numCiocb
+ pring
->numRiocb
);
2224 if (totiocb
> MAX_SLI2_IOCB
) {
2225 /* Too many cmd / rsp ring entries in SLI2 SLIM */
2226 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2227 "%d:0462 Too many cmd / rsp ring entries in "
2228 "SLI2 SLIM Data: x%x x%x\n",
2229 phba
->brd_no
, totiocb
, MAX_SLI2_IOCB
);
2236 lpfc_sli_queue_setup(struct lpfc_hba
* phba
)
2238 struct lpfc_sli
*psli
;
2239 struct lpfc_sli_ring
*pring
;
2243 spin_lock_irq(phba
->host
->host_lock
);
2244 INIT_LIST_HEAD(&psli
->mboxq
);
2245 /* Initialize list headers for txq and txcmplq as double linked lists */
2246 for (i
= 0; i
< psli
->num_rings
; i
++) {
2247 pring
= &psli
->ring
[i
];
2249 pring
->next_cmdidx
= 0;
2250 pring
->local_getidx
= 0;
2252 INIT_LIST_HEAD(&pring
->txq
);
2253 INIT_LIST_HEAD(&pring
->txcmplq
);
2254 INIT_LIST_HEAD(&pring
->iocb_continueq
);
2255 INIT_LIST_HEAD(&pring
->postbufq
);
2256 cnt
= pring
->fast_iotag
;
2257 spin_unlock_irq(phba
->host
->host_lock
);
2259 pring
->fast_lookup
=
2260 kmalloc(cnt
* sizeof (struct lpfc_iocbq
*),
2262 if (pring
->fast_lookup
== 0) {
2265 memset((char *)pring
->fast_lookup
, 0,
2266 cnt
* sizeof (struct lpfc_iocbq
*));
2268 spin_lock_irq(phba
->host
->host_lock
);
2270 spin_unlock_irq(phba
->host
->host_lock
);
2275 lpfc_sli_hba_down(struct lpfc_hba
* phba
)
2277 struct lpfc_sli
*psli
;
2278 struct lpfc_sli_ring
*pring
;
2280 struct lpfc_iocbq
*iocb
, *next_iocb
;
2281 IOCB_t
*icmd
= NULL
;
2283 unsigned long flags
= 0;
2286 lpfc_hba_down_prep(phba
);
2288 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
2290 for (i
= 0; i
< psli
->num_rings
; i
++) {
2291 pring
= &psli
->ring
[i
];
2292 pring
->flag
|= LPFC_DEFERRED_RING_EVENT
;
2295 * Error everything on the txq since these iocbs have not been
2296 * given to the FW yet.
2300 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
2301 list_del_init(&iocb
->list
);
2302 if (iocb
->iocb_cmpl
) {
2304 icmd
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
2305 icmd
->un
.ulpWord
[4] = IOERR_SLI_DOWN
;
2306 spin_unlock_irqrestore(phba
->host
->host_lock
,
2308 (iocb
->iocb_cmpl
) (phba
, iocb
, iocb
);
2309 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
2311 list_add_tail(&iocb
->list
,
2312 &phba
->lpfc_iocb_list
);
2316 INIT_LIST_HEAD(&(pring
->txq
));
2318 if (pring
->fast_lookup
) {
2319 kfree(pring
->fast_lookup
);
2320 pring
->fast_lookup
= NULL
;
2325 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
2327 /* Return any active mbox cmds */
2328 del_timer_sync(&psli
->mbox_tmo
);
2329 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
2330 phba
->work_hba_events
&= ~WORKER_MBOX_TMO
;
2331 if (psli
->mbox_active
) {
2332 pmb
= psli
->mbox_active
;
2333 pmb
->mb
.mbxStatus
= MBX_NOT_FINISHED
;
2334 if (pmb
->mbox_cmpl
) {
2335 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
2336 pmb
->mbox_cmpl(phba
,pmb
);
2337 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
2340 psli
->sli_flag
&= ~LPFC_SLI_MBOX_ACTIVE
;
2341 psli
->mbox_active
= NULL
;
2343 /* Return any pending mbox cmds */
2344 while ((pmb
= lpfc_mbox_get(phba
)) != NULL
) {
2345 pmb
->mb
.mbxStatus
= MBX_NOT_FINISHED
;
2346 if (pmb
->mbox_cmpl
) {
2347 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
2348 pmb
->mbox_cmpl(phba
,pmb
);
2349 spin_lock_irqsave(phba
->host
->host_lock
, flags
);
2353 INIT_LIST_HEAD(&psli
->mboxq
);
2355 spin_unlock_irqrestore(phba
->host
->host_lock
, flags
);
2358 * Provided the hba is not in an error state, reset it. It is not
2359 * capable of IO anymore.
2361 if (phba
->hba_state
!= LPFC_HBA_ERROR
) {
2362 phba
->hba_state
= LPFC_INIT_START
;
2363 lpfc_sli_brdreset(phba
, 1);
2370 lpfc_sli_pcimem_bcopy(void *srcp
, void *destp
, uint32_t cnt
)
2372 uint32_t *src
= srcp
;
2373 uint32_t *dest
= destp
;
2377 for (i
= 0; i
< (int)cnt
; i
+= sizeof (uint32_t)) {
2379 ldata
= le32_to_cpu(ldata
);
2387 lpfc_sli_ringpostbuf_put(struct lpfc_hba
* phba
, struct lpfc_sli_ring
* pring
,
2388 struct lpfc_dmabuf
* mp
)
2390 /* Stick struct lpfc_dmabuf at end of postbufq so driver can look it up
2392 list_add_tail(&mp
->list
, &pring
->postbufq
);
2394 pring
->postbufq_cnt
++;
2399 struct lpfc_dmabuf
*
2400 lpfc_sli_ringpostbuf_get(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
2403 struct lpfc_dmabuf
*mp
, *next_mp
;
2404 struct list_head
*slp
= &pring
->postbufq
;
2406 /* Search postbufq, from the begining, looking for a match on phys */
2407 list_for_each_entry_safe(mp
, next_mp
, &pring
->postbufq
, list
) {
2408 if (mp
->phys
== phys
) {
2409 list_del_init(&mp
->list
);
2410 pring
->postbufq_cnt
--;
2415 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2416 "%d:0410 Cannot find virtual addr for mapped buf on "
2417 "ring %d Data x%llx x%p x%p x%x\n",
2418 phba
->brd_no
, pring
->ringno
, (unsigned long long)phys
,
2419 slp
->next
, slp
->prev
, pring
->postbufq_cnt
);
2424 lpfc_sli_abort_elsreq_cmpl(struct lpfc_hba
* phba
, struct lpfc_iocbq
* cmdiocb
,
2425 struct lpfc_iocbq
* rspiocb
)
2427 struct lpfc_dmabuf
*buf_ptr
, *buf_ptr1
;
2428 /* Free the resources associated with the ELS_REQUEST64 IOCB the driver
2430 * In this case, context2 = cmd, context2->next = rsp, context3 = bpl
2432 if (cmdiocb
->context2
) {
2433 buf_ptr1
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
2435 /* Free the response IOCB before completing the abort
2438 list_remove_head((&buf_ptr1
->list
), buf_ptr
,
2439 struct lpfc_dmabuf
, list
);
2441 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
2444 lpfc_mbuf_free(phba
, buf_ptr1
->virt
, buf_ptr1
->phys
);
2448 if (cmdiocb
->context3
) {
2449 buf_ptr
= (struct lpfc_dmabuf
*) cmdiocb
->context3
;
2450 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
2454 list_add_tail(&cmdiocb
->list
, &phba
->lpfc_iocb_list
);
2459 lpfc_sli_issue_abort_iotag32(struct lpfc_hba
* phba
,
2460 struct lpfc_sli_ring
* pring
,
2461 struct lpfc_iocbq
* cmdiocb
)
2463 struct list_head
*lpfc_iocb_list
= &phba
->lpfc_iocb_list
;
2464 struct lpfc_iocbq
*abtsiocbp
= NULL
;
2465 IOCB_t
*icmd
= NULL
;
2466 IOCB_t
*iabt
= NULL
;
2468 /* issue ABTS for this IOCB based on iotag */
2469 list_remove_head(lpfc_iocb_list
, abtsiocbp
, struct lpfc_iocbq
, list
);
2470 if (abtsiocbp
== NULL
)
2472 memset(abtsiocbp
, 0, sizeof (struct lpfc_iocbq
));
2474 iabt
= &abtsiocbp
->iocb
;
2475 icmd
= &cmdiocb
->iocb
;
2476 switch (icmd
->ulpCommand
) {
2477 case CMD_ELS_REQUEST64_CR
:
2478 /* Even though we abort the ELS command, the firmware may access
2479 * the BPL or other resources before it processes our
2480 * ABORT_MXRI64. Thus we must delay reusing the cmdiocb
2481 * resources till the actual abort request completes.
2483 abtsiocbp
->context1
= (void *)((unsigned long)icmd
->ulpCommand
);
2484 abtsiocbp
->context2
= cmdiocb
->context2
;
2485 abtsiocbp
->context3
= cmdiocb
->context3
;
2486 cmdiocb
->context2
= NULL
;
2487 cmdiocb
->context3
= NULL
;
2488 abtsiocbp
->iocb_cmpl
= lpfc_sli_abort_elsreq_cmpl
;
2491 list_add_tail(&abtsiocbp
->list
, lpfc_iocb_list
);
2495 iabt
->un
.amxri
.abortType
= ABORT_TYPE_ABTS
;
2496 iabt
->un
.amxri
.iotag32
= icmd
->un
.elsreq64
.bdl
.ulpIoTag32
;
2499 iabt
->ulpClass
= CLASS3
;
2500 iabt
->ulpCommand
= CMD_ABORT_MXRI64_CN
;
2502 if (lpfc_sli_issue_iocb(phba
, pring
, abtsiocbp
, 0) == IOCB_ERROR
) {
2503 list_add_tail(&abtsiocbp
->list
, lpfc_iocb_list
);
2511 lpfc_sli_validate_iocb_cmd(struct lpfc_scsi_buf
*lpfc_cmd
, uint16_t tgt_id
,
2512 uint64_t lun_id
, struct lpfc_iocbq
*iocb
,
2513 uint32_t ctx
, lpfc_ctx_cmd ctx_cmd
)
2517 if (lpfc_cmd
== NULL
)
2522 if ((lpfc_cmd
->pCmd
->device
->id
== tgt_id
) &&
2523 (lpfc_cmd
->pCmd
->device
->lun
== lun_id
))
2527 if (lpfc_cmd
->pCmd
->device
->id
== tgt_id
)
2531 if (iocb
->iocb
.ulpContext
== ctx
)
2537 printk(KERN_ERR
"%s: Unknown context cmd type, value %d\n",
2538 __FUNCTION__
, ctx_cmd
);
2546 lpfc_sli_sum_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
2547 uint16_t tgt_id
, uint64_t lun_id
, lpfc_ctx_cmd ctx_cmd
)
2549 struct lpfc_iocbq
*iocb
, *next_iocb
;
2551 struct lpfc_scsi_buf
*lpfc_cmd
;
2552 int sum
= 0, ret_val
= 0;
2554 /* Next check the txcmplq */
2555 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
2558 /* Must be a FCP command */
2559 if ((cmd
->ulpCommand
!= CMD_FCP_ICMND64_CR
) &&
2560 (cmd
->ulpCommand
!= CMD_FCP_IWRITE64_CR
) &&
2561 (cmd
->ulpCommand
!= CMD_FCP_IREAD64_CR
)) {
2565 /* context1 MUST be a struct lpfc_scsi_buf */
2566 lpfc_cmd
= (struct lpfc_scsi_buf
*) (iocb
->context1
);
2567 ret_val
= lpfc_sli_validate_iocb_cmd(lpfc_cmd
, tgt_id
, lun_id
,
2577 lpfc_sli_abort_iocb(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
2578 uint16_t tgt_id
, uint64_t lun_id
, uint32_t ctx
,
2579 lpfc_ctx_cmd abort_cmd
)
2581 struct lpfc_iocbq
*iocb
, *next_iocb
;
2582 struct lpfc_iocbq
*abtsiocb
= NULL
;
2583 struct list_head
*lpfc_iocb_list
= &phba
->lpfc_iocb_list
;
2585 struct lpfc_scsi_buf
*lpfc_cmd
;
2586 int errcnt
= 0, ret_val
= 0;
2588 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
2591 /* Must be a FCP command */
2592 if ((cmd
->ulpCommand
!= CMD_FCP_ICMND64_CR
) &&
2593 (cmd
->ulpCommand
!= CMD_FCP_IWRITE64_CR
) &&
2594 (cmd
->ulpCommand
!= CMD_FCP_IREAD64_CR
)) {
2598 /* context1 MUST be a struct lpfc_scsi_buf */
2599 lpfc_cmd
= (struct lpfc_scsi_buf
*) (iocb
->context1
);
2600 ret_val
= lpfc_sli_validate_iocb_cmd(lpfc_cmd
, tgt_id
, lun_id
,
2601 iocb
, ctx
, abort_cmd
);
2605 /* issue ABTS for this IOCB based on iotag */
2606 list_remove_head(lpfc_iocb_list
, abtsiocb
, struct lpfc_iocbq
,
2608 if (abtsiocb
== NULL
) {
2612 memset(abtsiocb
, 0, sizeof (struct lpfc_iocbq
));
2614 abtsiocb
->iocb
.un
.acxri
.abortType
= ABORT_TYPE_ABTS
;
2615 abtsiocb
->iocb
.un
.acxri
.abortContextTag
= cmd
->ulpContext
;
2616 abtsiocb
->iocb
.un
.acxri
.abortIoTag
= cmd
->ulpIoTag
;
2617 abtsiocb
->iocb
.ulpLe
= 1;
2618 abtsiocb
->iocb
.ulpClass
= cmd
->ulpClass
;
2620 if (phba
->hba_state
>= LPFC_LINK_UP
)
2621 abtsiocb
->iocb
.ulpCommand
= CMD_ABORT_XRI_CN
;
2623 abtsiocb
->iocb
.ulpCommand
= CMD_CLOSE_XRI_CN
;
2625 ret_val
= lpfc_sli_issue_iocb(phba
, pring
, abtsiocb
, 0);
2626 if (ret_val
== IOCB_ERROR
) {
2627 list_add_tail(&abtsiocb
->list
, lpfc_iocb_list
);
2637 lpfc_sli_wake_iocb_high_priority(struct lpfc_hba
* phba
,
2638 struct lpfc_iocbq
* queue1
,
2639 struct lpfc_iocbq
* queue2
)
2641 if (queue1
->context2
&& queue2
)
2642 memcpy(queue1
->context2
, queue2
, sizeof (struct lpfc_iocbq
));
2644 /* The waiter is looking for LPFC_IO_HIPRI bit to be set
2645 as a signal to wake up */
2646 queue1
->iocb_flag
|= LPFC_IO_HIPRI
;
2651 lpfc_sli_issue_iocb_wait_high_priority(struct lpfc_hba
* phba
,
2652 struct lpfc_sli_ring
* pring
,
2653 struct lpfc_iocbq
* piocb
,
2655 struct lpfc_iocbq
* prspiocbq
,
2658 int j
, delay_time
, retval
= IOCB_ERROR
;
2660 /* The caller must left context1 empty. */
2661 if (piocb
->context_un
.hipri_wait_queue
!= 0) {
2666 * If the caller has provided a response iocbq buffer, context2 must
2667 * be NULL or its an error.
2669 if (prspiocbq
&& piocb
->context2
) {
2673 piocb
->context2
= prspiocbq
;
2675 /* Setup callback routine and issue the command. */
2676 piocb
->iocb_cmpl
= lpfc_sli_wake_iocb_high_priority
;
2677 retval
= lpfc_sli_issue_iocb(phba
, pring
, piocb
,
2678 flag
| SLI_IOCB_HIGH_PRIORITY
);
2679 if (retval
!= IOCB_SUCCESS
) {
2680 piocb
->context2
= NULL
;
2685 * This high-priority iocb was sent out-of-band. Poll for its
2686 * completion rather than wait for a signal. Note that the host_lock
2687 * is held by the midlayer and must be released here to allow the
2688 * interrupt handlers to complete the IO and signal this routine via
2690 * Also, the delay_time is computed to be one second longer than
2691 * the scsi command timeout to give the FW time to abort on
2692 * timeout rather than the driver just giving up. Typically,
2693 * the midlayer does not specify a time for this command so the
2694 * driver is free to enforce its own timeout.
2697 delay_time
= ((timeout
+ 1) * 1000) >> 6;
2698 retval
= IOCB_ERROR
;
2699 spin_unlock_irq(phba
->host
->host_lock
);
2700 for (j
= 0; j
< 64; j
++) {
2702 if (piocb
->iocb_flag
& LPFC_IO_HIPRI
) {
2703 piocb
->iocb_flag
&= ~LPFC_IO_HIPRI
;
2704 retval
= IOCB_SUCCESS
;
2709 spin_lock_irq(phba
->host
->host_lock
);
2710 piocb
->context2
= NULL
;
2714 lpfc_sli_issue_mbox_wait(struct lpfc_hba
* phba
, LPFC_MBOXQ_t
* pmboxq
,
2717 DECLARE_WAIT_QUEUE_HEAD(done_q
);
2718 DECLARE_WAITQUEUE(wq_entry
, current
);
2719 uint32_t timeleft
= 0;
2722 /* The caller must leave context1 empty. */
2723 if (pmboxq
->context1
!= 0) {
2724 return (MBX_NOT_FINISHED
);
2727 /* setup wake call as IOCB callback */
2728 pmboxq
->mbox_cmpl
= lpfc_sli_wake_mbox_wait
;
2729 /* setup context field to pass wait_queue pointer to wake function */
2730 pmboxq
->context1
= &done_q
;
2732 /* start to sleep before we wait, to avoid races */
2733 set_current_state(TASK_INTERRUPTIBLE
);
2734 add_wait_queue(&done_q
, &wq_entry
);
2736 /* now issue the command */
2737 retval
= lpfc_sli_issue_mbox(phba
, pmboxq
, MBX_NOWAIT
);
2739 if (retval
== MBX_BUSY
|| retval
== MBX_SUCCESS
) {
2740 timeleft
= schedule_timeout(timeout
* HZ
);
2741 pmboxq
->context1
= NULL
;
2742 /* if schedule_timeout returns 0, we timed out and were not
2744 if (timeleft
== 0) {
2745 retval
= MBX_TIMEOUT
;
2747 retval
= MBX_SUCCESS
;
2752 set_current_state(TASK_RUNNING
);
2753 remove_wait_queue(&done_q
, &wq_entry
);
2758 lpfc_intr_handler(int irq
, void *dev_id
, struct pt_regs
* regs
)
2760 struct lpfc_hba
*phba
;
2762 uint32_t work_ha_copy
;
2763 unsigned long status
;
2768 * Get the driver's phba structure from the dev_id and
2769 * assume the HBA is not interrupting.
2771 phba
= (struct lpfc_hba
*) dev_id
;
2773 if (unlikely(!phba
))
2776 phba
->sli
.slistat
.sli_intr
++;
2779 * Call the HBA to see if it is interrupting. If not, don't claim
2783 /* Ignore all interrupts during initialization. */
2784 if (unlikely(phba
->hba_state
< LPFC_LINK_DOWN
))
2788 * Read host attention register to determine interrupt source
2789 * Clear Attention Sources, except Error Attention (to
2790 * preserve status) and Link Attention
2792 spin_lock(phba
->host
->host_lock
);
2793 ha_copy
= readl(phba
->HAregaddr
);
2794 writel((ha_copy
& ~(HA_LATT
| HA_ERATT
)), phba
->HAregaddr
);
2795 readl(phba
->HAregaddr
); /* flush */
2796 spin_unlock(phba
->host
->host_lock
);
2798 if (unlikely(!ha_copy
))
2801 work_ha_copy
= ha_copy
& phba
->work_ha_mask
;
2803 if (unlikely(work_ha_copy
)) {
2804 if (work_ha_copy
& HA_LATT
) {
2805 if (phba
->sli
.sli_flag
& LPFC_PROCESS_LA
) {
2807 * Turn off Link Attention interrupts
2808 * until CLEAR_LA done
2810 spin_lock(phba
->host
->host_lock
);
2811 phba
->sli
.sli_flag
&= ~LPFC_PROCESS_LA
;
2812 control
= readl(phba
->HCregaddr
);
2813 control
&= ~HC_LAINT_ENA
;
2814 writel(control
, phba
->HCregaddr
);
2815 readl(phba
->HCregaddr
); /* flush */
2816 spin_unlock(phba
->host
->host_lock
);
2819 work_ha_copy
&= ~HA_LATT
;
2822 if (work_ha_copy
& ~(HA_ERATT
|HA_MBATT
|HA_LATT
)) {
2823 for (i
= 0; i
< phba
->sli
.num_rings
; i
++) {
2824 if (work_ha_copy
& (HA_RXATT
<< (4*i
))) {
2826 * Turn off Slow Rings interrupts
2828 spin_lock(phba
->host
->host_lock
);
2829 control
= readl(phba
->HCregaddr
);
2830 control
&= ~(HC_R0INT_ENA
<< i
);
2831 writel(control
, phba
->HCregaddr
);
2832 readl(phba
->HCregaddr
); /* flush */
2833 spin_unlock(phba
->host
->host_lock
);
2838 if (work_ha_copy
& HA_ERATT
) {
2839 phba
->hba_state
= LPFC_HBA_ERROR
;
2841 * There was a link/board error. Read the
2842 * status register to retrieve the error event
2845 phba
->sli
.slistat
.err_attn_event
++;
2846 /* Save status info */
2847 phba
->work_hs
= readl(phba
->HSregaddr
);
2848 phba
->work_status
[0] = readl(phba
->MBslimaddr
+ 0xa8);
2849 phba
->work_status
[1] = readl(phba
->MBslimaddr
+ 0xac);
2851 /* Clear Chip error bit */
2852 writel(HA_ERATT
, phba
->HAregaddr
);
2853 readl(phba
->HAregaddr
); /* flush */
2856 * Reseting the HBA is the only reliable way
2857 * to shutdown interrupt when there is a
2860 lpfc_sli_send_reset(phba
, phba
->hba_state
);
2863 spin_lock(phba
->host
->host_lock
);
2864 phba
->work_ha
|= work_ha_copy
;
2865 if (phba
->work_wait
)
2866 wake_up(phba
->work_wait
);
2867 spin_unlock(phba
->host
->host_lock
);
2870 ha_copy
&= ~(phba
->work_ha_mask
);
2873 * Process all events on FCP ring. Take the optimized path for
2874 * FCP IO. Any other IO is slow path and is handled by
2875 * the worker thread.
2877 status
= (ha_copy
& (HA_RXMASK
<< (4*LPFC_FCP_RING
)));
2878 status
>>= (4*LPFC_FCP_RING
);
2879 if (status
& HA_RXATT
)
2880 lpfc_sli_handle_fast_ring_event(phba
,
2881 &phba
->sli
.ring
[LPFC_FCP_RING
],
2885 } /* lpfc_intr_handler */