vserver 2.0 rc7
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_sli.c
index e9068e7..8d14b28 100644 (file)
  *******************************************************************/
 
 /*
- * $Id: lpfc_sli.c 1.178 2004/11/23 16:57:11EST sf_support Exp  $
+ * $Id: lpfc_sli.c 1.232 2005/04/13 11:59:16EDT sf_support Exp  $
  */
 
-#include <linux/version.h>
 #include <linux/blkdev.h>
-#include <linux/dma-mapping.h>
 #include <linux/pci.h>
-#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 
+#include "lpfc_hw.h"
 #include "lpfc_sli.h"
 #include "lpfc_disc.h"
 #include "lpfc_scsi.h"
 #include "lpfc.h"
 #include "lpfc_crtn.h"
-#include "lpfc_hw.h"
 #include "lpfc_logmsg.h"
-#include "lpfc_mem.h"
 #include "lpfc_compat.h"
 
-static int lpfc_sli_reset_on_init = 1;
-
 /*
  * Define macro to log: Mailbox command x%x cannot issue Data
  * This allows multiple uses of lpfc_msgBlk0311
  * w/o perturbing log msg utility.
-*/
+ */
 #define LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag) \
                        lpfc_printf_log(phba, \
                                KERN_INFO, \
@@ -58,202 +54,101 @@ static int lpfc_sli_reset_on_init = 1;
                                phba->brd_no, \
                                mb->mbxCommand,         \
                                phba->hba_state,        \
-                               psli->sliinit.sli_flag, \
+                               psli->sli_flag, \
                                flag);
 
 
-/* This will save a huge switch to determine if the IOCB cmd
- * is unsolicited or solicited.
- */
-#define LPFC_UNKNOWN_IOCB 0
-#define LPFC_UNSOL_IOCB   1
-#define LPFC_SOL_IOCB     2
-#define LPFC_ABORT_IOCB   3
-static uint8_t lpfc_sli_iocb_cmd_type[CMD_MAX_IOCB_CMD] = {
-       LPFC_UNKNOWN_IOCB,      /* 0x00 */
-       LPFC_UNSOL_IOCB,        /* CMD_RCV_SEQUENCE_CX     0x01 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_SEQUENCE_CR    0x02 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_SEQUENCE_CX    0x03 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_BCAST_CN       0x04 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_BCAST_CX       0x05 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_QUE_RING_BUF_CN     0x06 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_QUE_XRI_BUF_CX      0x07 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_IOCB_CONTINUE_CN    0x08 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_RET_XRI_BUF_CX      0x09 */
-       LPFC_SOL_IOCB,          /* CMD_ELS_REQUEST_CR      0x0A */
-       LPFC_SOL_IOCB,          /* CMD_ELS_REQUEST_CX      0x0B */
-       LPFC_UNKNOWN_IOCB,      /* 0x0C */
-       LPFC_UNSOL_IOCB,        /* CMD_RCV_ELS_REQ_CX      0x0D */
-       LPFC_ABORT_IOCB,        /* CMD_ABORT_XRI_CN        0x0E */
-       LPFC_ABORT_IOCB,        /* CMD_ABORT_XRI_CX        0x0F */
-       LPFC_ABORT_IOCB,        /* CMD_CLOSE_XRI_CR        0x10 */
-       LPFC_ABORT_IOCB,        /* CMD_CLOSE_XRI_CX        0x11 */
-       LPFC_SOL_IOCB,          /* CMD_CREATE_XRI_CR       0x12 */
-       LPFC_SOL_IOCB,          /* CMD_CREATE_XRI_CX       0x13 */
-       LPFC_SOL_IOCB,          /* CMD_GET_RPI_CN          0x14 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_ELS_RSP_CX     0x15 */
-       LPFC_SOL_IOCB,          /* CMD_GET_RPI_CR          0x16 */
-       LPFC_ABORT_IOCB,        /* CMD_XRI_ABORTED_CX      0x17 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IWRITE_CR       0x18 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IWRITE_CX       0x19 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IREAD_CR        0x1A */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IREAD_CX        0x1B */
-       LPFC_SOL_IOCB,          /* CMD_FCP_ICMND_CR        0x1C */
-       LPFC_SOL_IOCB,          /* CMD_FCP_ICMND_CX        0x1D */
-       LPFC_UNKNOWN_IOCB,      /* 0x1E */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TSEND_CX        0x1F */
-       LPFC_SOL_IOCB,          /* CMD_ADAPTER_MSG         0x20 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TRECEIVE_CX     0x21 */
-       LPFC_SOL_IOCB,          /* CMD_ADAPTER_DUMP        0x22 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TRSP_CX         0x23 */
-       /* 0x24 - 0x80 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       /* 0x30 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       /* 0x40 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       /* 0x50 */
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
+/* There are only four IOCB completion types. */
+typedef enum _lpfc_iocb_type {
        LPFC_UNKNOWN_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_UNSOL_IOCB,
        LPFC_UNSOL_IOCB,
        LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
-
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       /* 0x60 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       /* 0x70 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       /* 0x80 */
-       LPFC_UNKNOWN_IOCB,
-       LPFC_UNSOL_IOCB,        /* CMD_RCV_SEQUENCE64_CX   0x81 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_SEQUENCE64_CR  0x82 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_SEQUENCE64_CX  0x83 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_BCAST64_CN     0x84 */
-       LPFC_SOL_IOCB,          /* CMD_XMIT_BCAST64_CX     0x85 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_QUE_RING_BUF64_CN   0x86 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_QUE_XRI_BUF64_CX    0x87 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_IOCB_CONTINUE64_CN  0x88 */
-       LPFC_UNKNOWN_IOCB,      /* CMD_RET_XRI_BUF64_CX    0x89 */
-       LPFC_SOL_IOCB,          /* CMD_ELS_REQUEST64_CR    0x8A */
-       LPFC_SOL_IOCB,          /* CMD_ELS_REQUEST64_CX    0x8B */
-       LPFC_ABORT_IOCB,        /* CMD_ABORT_MXRI64_CN     0x8C */
-       LPFC_UNSOL_IOCB,        /* CMD_RCV_ELS_REQ64_CX    0x8D */
-       /* 0x8E - 0x94 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB,
-       LPFC_SOL_IOCB,          /* CMD_XMIT_ELS_RSP64_CX   0x95 */
-       LPFC_UNKNOWN_IOCB,      /* 0x96 */
-       LPFC_UNKNOWN_IOCB,      /* 0x97 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IWRITE64_CR     0x98 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IWRITE64_CX     0x99 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IREAD64_CR      0x9A */
-       LPFC_SOL_IOCB,          /* CMD_FCP_IREAD64_CX      0x9B */
-       LPFC_SOL_IOCB,          /* CMD_FCP_ICMND64_CR      0x9C */
-       LPFC_SOL_IOCB,          /* CMD_FCP_ICMND64_CX      0x9D */
-       LPFC_UNKNOWN_IOCB,      /* 0x9E */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TSEND64_CX      0x9F */
-       LPFC_UNKNOWN_IOCB,      /* 0xA0 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TRECEIVE64_CX   0xA1 */
-       LPFC_UNKNOWN_IOCB,      /* 0xA2 */
-       LPFC_SOL_IOCB,          /* CMD_FCP_TRSP64_CX       0xA3 */
-       /* 0xA4 - 0xC1 */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_SOL_IOCB,          /* CMD_GEN_REQUEST64_CR    0xC2 */
-       LPFC_SOL_IOCB,          /* CMD_GEN_REQUEST64_CX    0xC3 */
-       /* 0xC4 - 0xCF */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
+       LPFC_ABORT_IOCB
+} lpfc_iocb_type;
 
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,          /* CMD_SENDTEXT_CR              0xD1 */
-       LPFC_SOL_IOCB,          /* CMD_SENDTEXT_CX              0xD2 */
-       LPFC_SOL_IOCB,          /* CMD_RCV_LOGIN                0xD3 */
-       LPFC_SOL_IOCB,          /* CMD_ACCEPT_LOGIN             0xD4 */
-       LPFC_SOL_IOCB,          /* CMD_REJECT_LOGIN             0xD5 */
-       LPFC_UNSOL_IOCB,
-       /* 0xD7 - 0xDF */
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB, LPFC_UNKNOWN_IOCB,
-       /* 0xE0 */
-       LPFC_UNSOL_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_SOL_IOCB,
-       LPFC_UNSOL_IOCB
-};
+/*
+ * Translate the iocb command to an iocb command type used to decide the final
+ * disposition of each completed IOCB.
+ */
+static lpfc_iocb_type
+lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
+{
+       lpfc_iocb_type type = LPFC_UNKNOWN_IOCB;
+
+       if (iocb_cmnd > CMD_MAX_IOCB_CMD)
+               return 0;
+
+       switch (iocb_cmnd) {
+       case CMD_XMIT_SEQUENCE_CR:
+       case CMD_XMIT_SEQUENCE_CX:
+       case CMD_XMIT_BCAST_CN:
+       case CMD_XMIT_BCAST_CX:
+       case CMD_ELS_REQUEST_CR:
+       case CMD_ELS_REQUEST_CX:
+       case CMD_CREATE_XRI_CR:
+       case CMD_CREATE_XRI_CX:
+       case CMD_GET_RPI_CN:
+       case CMD_XMIT_ELS_RSP_CX:
+       case CMD_GET_RPI_CR:
+       case CMD_FCP_IWRITE_CR:
+       case CMD_FCP_IWRITE_CX:
+       case CMD_FCP_IREAD_CR:
+       case CMD_FCP_IREAD_CX:
+       case CMD_FCP_ICMND_CR:
+       case CMD_FCP_ICMND_CX:
+       case CMD_ADAPTER_MSG:
+       case CMD_ADAPTER_DUMP:
+       case CMD_XMIT_SEQUENCE64_CR:
+       case CMD_XMIT_SEQUENCE64_CX:
+       case CMD_XMIT_BCAST64_CN:
+       case CMD_XMIT_BCAST64_CX:
+       case CMD_ELS_REQUEST64_CR:
+       case CMD_ELS_REQUEST64_CX:
+       case CMD_FCP_IWRITE64_CR:
+       case CMD_FCP_IWRITE64_CX:
+       case CMD_FCP_IREAD64_CR:
+       case CMD_FCP_IREAD64_CX:
+       case CMD_FCP_ICMND64_CR:
+       case CMD_FCP_ICMND64_CX:
+       case CMD_GEN_REQUEST64_CR:
+       case CMD_GEN_REQUEST64_CX:
+       case CMD_XMIT_ELS_RSP64_CX:
+               type = LPFC_SOL_IOCB;
+               break;
+       case CMD_ABORT_XRI_CN:
+       case CMD_ABORT_XRI_CX:
+       case CMD_CLOSE_XRI_CN:
+       case CMD_CLOSE_XRI_CX:
+       case CMD_XRI_ABORTED_CX:
+       case CMD_ABORT_MXRI64_CN:
+               type = LPFC_ABORT_IOCB;
+               break;
+       case CMD_RCV_SEQUENCE_CX:
+       case CMD_RCV_ELS_REQ_CX:
+       case CMD_RCV_SEQUENCE64_CX:
+       case CMD_RCV_ELS_REQ64_CX:
+               type = LPFC_UNSOL_IOCB;
+               break;
+       default:
+               type = LPFC_UNKNOWN_IOCB;
+               break;
+       }
 
+       return type;
+}
 
 static int
-lpfc_sli_ring_map(struct lpfc_hba * phba)
+lpfc_sli_ring_map(struct lpfc_hba * phba, LPFC_MBOXQ_t *pmb)
 {
-       struct lpfc_sli *psli;
-       LPFC_MBOXQ_t *pmb;
-       MAILBOX_t *pmbox;
-       int i;
-
-       psli = &phba->sli;
-
-       /* Get a Mailbox buffer to setup mailbox commands for HBA
-          initialization */
-       if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
-                                                 GFP_ATOMIC)) == 0) {
-               phba->hba_state = LPFC_HBA_ERROR;
-               return -ENOMEM;
-       }
-       pmbox = &pmb->mb;
+       struct lpfc_sli *psli = &phba->sli;
+       MAILBOX_t *pmbox = &pmb->mb;
+       int i, rc;
 
-       /* Initialize the struct lpfc_sli_ring structure for each ring */
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
-               /* Issue a CONFIG_RING mailbox command for each ring */
+       for (i = 0; i < psli->num_rings; i++) {
                phba->hba_state = LPFC_INIT_MBX_CMDS;
                lpfc_config_ring(phba, i, pmb);
-               if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
-                       /* Adapter failed to init, mbxCmd <cmd> CFG_RING,
-                          mbxStatus <status>, ring <num> */
+               rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
+               if (rc != MBX_SUCCESS) {
                        lpfc_printf_log(phba,
                                        KERN_ERR,
                                        LOG_INIT,
@@ -265,11 +160,9 @@ lpfc_sli_ring_map(struct lpfc_hba * phba)
                                        pmbox->mbxStatus,
                                        i);
                        phba->hba_state = LPFC_HBA_ERROR;
-                       mempool_free( pmb, phba->mbox_mem_pool);
                        return -ENXIO;
                }
        }
-       mempool_free( pmb, phba->mbox_mem_pool);
        return 0;
 }
 
@@ -281,15 +174,17 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba,
 
        list_add_tail(&piocb->list, &pring->txcmplq);
        pring->txcmplq_cnt++;
+       if (unlikely(pring->ringno == LPFC_ELS_RING))
+               mod_timer(&phba->els_tmofunc,
+                                       jiffies + HZ * (phba->fc_ratov << 1));
 
        if (pring->fast_lookup) {
                /* Setup fast lookup based on iotag for completion */
                iotag = piocb->iocb.ulpIoTag;
-               if (iotag && (iotag
-                     < phba->sli.sliinit.ringinit[pring->ringno].fast_iotag))
+               if (iotag && (iotag < pring->fast_iotag))
                        *(pring->fast_lookup + iotag) = piocb;
                else {
-                       
+
                        /* Cmd ring <ringno> put: iotag <iotag> greater then
                           configured max <fast_iotag> wd0 <icmd> */
                        lpfc_printf_log(phba,
@@ -299,8 +194,8 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba,
                                        "greater then configured max x%x "
                                        "wd0 x%x\n",
                                        phba->brd_no,
-                                       pring->ringno, iotag, phba->sli.sliinit
-                                       .ringinit[pring->ringno].fast_iotag,
+                                       pring->ringno, iotag,
+                                       pring->fast_iotag,
                                        *(((uint32_t *)(&piocb->iocb)) + 7));
                }
        }
@@ -312,17 +207,16 @@ lpfc_sli_ringtx_get(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
 {
        struct list_head *dlp;
        struct lpfc_iocbq *cmd_iocb;
-       struct lpfc_iocbq *next_iocb;
 
        dlp = &pring->txq;
        cmd_iocb = NULL;
-       next_iocb = (struct lpfc_iocbq *) pring->txq.next;
-       if (next_iocb != (struct lpfc_iocbq *) & pring->txq) {
+       list_remove_head((&pring->txq), cmd_iocb,
+                        struct lpfc_iocbq,
+                        list);
+       if (cmd_iocb) {
                /* If the first ptr is not equal to the list header,
                 * deque the IOCBQ_t and return it.
                 */
-               cmd_iocb = next_iocb;
-               list_del(&cmd_iocb->list);
                pring->txq_cnt--;
        }
        return (cmd_iocb);
@@ -333,16 +227,15 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
 {
        MAILBOX_t *mbox = (MAILBOX_t *)phba->sli.MBhostaddr;
        PGP *pgp = (PGP *)&mbox->us.s2.port[pring->ringno];
-       uint32_t  max_cmd_idx =
-               phba->sli.sliinit.ringinit[pring->ringno].numCiocb;
+       uint32_t  max_cmd_idx = pring->numCiocb;
        IOCB_t *iocb = NULL;
-       
-       if((pring->next_cmdidx == pring->cmdidx) &&
+
+       if ((pring->next_cmdidx == pring->cmdidx) &&
           (++pring->next_cmdidx >= max_cmd_idx))
                pring->next_cmdidx = 0;
 
        if (unlikely(pring->local_getidx == pring->next_cmdidx)) {
-               
+
                pring->local_getidx = le32_to_cpu(pgp->cmdGetInx);
 
                if (unlikely(pring->local_getidx >= max_cmd_idx)) {
@@ -353,8 +246,15 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
                                        pring->local_getidx, max_cmd_idx);
 
                        phba->hba_state = LPFC_HBA_ERROR;
-                       lpfc_handle_eratt(phba, HS_FFER3);
-                       
+                       /*
+                        * All error attention handlers are posted to
+                        * worker thread
+                        */
+                       phba->work_ha |= HA_ERATT;
+                       phba->work_hs = HS_FFER3;
+                       if (phba->work_wait)
+                               wake_up(phba->work_wait);
+
                        return NULL;
                }
 
@@ -367,26 +267,59 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
        return iocb;
 }
 
+static uint32_t
+lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
+{
+       uint32_t search_start;
+
+       if (pring->fast_lookup == NULL) {
+               pring->iotag_ctr++;
+               if (pring->iotag_ctr >= pring->iotag_max)
+                       pring->iotag_ctr = 1;
+               return pring->iotag_ctr;
+       }
+
+       search_start = pring->iotag_ctr;
+
+       do {
+               pring->iotag_ctr++;
+               if (pring->iotag_ctr >= pring->fast_iotag)
+                       pring->iotag_ctr = 1;
+
+               if (*(pring->fast_lookup + pring->iotag_ctr) == NULL)
+                       return pring->iotag_ctr;
+
+       } while (pring->iotag_ctr != search_start);
+
+       /*
+        * Outstanding I/O count for ring <ringno> is at max <fast_iotag>
+        */
+       lpfc_printf_log(phba,
+               KERN_ERR,
+               LOG_SLI,
+               "%d:0318 Outstanding I/O count for ring %d is at max x%x\n",
+               phba->brd_no,
+               pring->ringno,
+               pring->fast_iotag);
+       return (0);
+}
+
 static void
 lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                IOCB_t *iocb, struct lpfc_iocbq *nextiocb)
 {
-       struct lpfc_sli *psli = &phba->sli;
-       int ringno = pring->ringno;
-
        /*
-        * Alloocate and set up an iotag
+        * Allocate and set up an iotag
         */
        nextiocb->iocb.ulpIoTag =
-               lpfc_sli_next_iotag(phba, &psli->ring[psli->fcp_ring]);
+               lpfc_sli_next_iotag(phba, &phba->sli.ring[phba->sli.fcp_ring]);
 
        /*
         * Issue iocb command to adapter
         */
-       lpfc_sli_pcimem_bcopy((uint32_t *)&nextiocb->iocb,
-                             (uint32_t *)(iocb), sizeof (IOCB_t));
+       lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, sizeof (IOCB_t));
        wmb();
-       psli->slistat.iocbCmd[ringno]++;
+       pring->stats.iocb_cmd++;
 
        /*
         * If there is no completion routine to call, we can release the
@@ -395,18 +328,17 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
         */
        if (nextiocb->iocb_cmpl)
                lpfc_sli_ringtxcmpl_put(phba, pring, nextiocb);
-       else
-               mempool_free(nextiocb, phba->iocb_mem_pool);
+       else {
+               list_add_tail(&nextiocb->list, &phba->lpfc_iocb_list);
+       }
 
        /*
         * Let the HBA know what IOCB slot will be the next one the
         * driver will put a command into.
         */
        pring->cmdidx = pring->next_cmdidx;
-       writeb(pring->cmdidx,
-              (u8 *)phba->MBslimaddr + (SLIMOFF + (ringno * 2)) * 4);
-
-       return;
+       writeb(pring->cmdidx, phba->MBslimaddr
+              + (SLIMOFF + (pring->ringno * 2)) * 4);
 }
 
 static void
@@ -426,7 +358,7 @@ lpfc_sli_update_full_ring(struct lpfc_hba * phba,
        writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr);
        readl(phba->CAregaddr); /* flush */
 
-       phba->sli.slistat.iocbCmdFull[ringno]++;
+       pring->stats.iocb_cmd_full++;
 }
 
 static void
@@ -446,7 +378,6 @@ lpfc_sli_update_ring(struct lpfc_hba * phba,
 static void
 lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
 {
-       struct lpfc_sli *psli = &phba->sli;
        IOCB_t *iocb;
        struct lpfc_iocbq *nextiocb;
 
@@ -459,14 +390,14 @@ lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
         */
        if (pring->txq_cnt &&
            (phba->hba_state > LPFC_LINK_DOWN) &&
-           (pring->ringno != psli->fcp_ring ||
-            psli->sliinit.sli_flag & LPFC_PROCESS_LA) &&
+           (pring->ringno != phba->sli.fcp_ring ||
+            phba->sli.sli_flag & LPFC_PROCESS_LA) &&
            !(pring->flag & LPFC_STOP_IOCB_MBX)) {
 
                while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) &&
                       (nextiocb = lpfc_sli_ringtx_get(phba, pring)))
                        lpfc_sli_submit_iocb(phba, pring, iocb, nextiocb);
-               
+
                if (iocb)
                        lpfc_sli_update_ring(phba, pring);
                else
@@ -480,23 +411,22 @@ lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
 static void
 lpfc_sli_turn_on_ring(struct lpfc_hba * phba, int ringno)
 {
-       struct lpfc_sli *psli;
-       struct lpfc_sli_ring *pring;
-       PGP *pgp;
-
-       psli = &phba->sli;
-       pring = &psli->ring[ringno];
-       pgp = (PGP *) & (((MAILBOX_t *)psli->MBhostaddr)->us.s2.port[ringno]);
+       PGP *pgp =
+               ((PGP *) &
+                (((MAILBOX_t *)phba->sli.MBhostaddr)->us.s2.port[ringno]));
 
        /* If the ring is active, flag it */
-       if (psli->ring[ringno].cmdringaddr) {
-               if (psli->ring[ringno].flag & LPFC_STOP_IOCB_MBX) {
-                       psli->ring[ringno].flag &= ~LPFC_STOP_IOCB_MBX;
+       if (phba->sli.ring[ringno].cmdringaddr) {
+               if (phba->sli.ring[ringno].flag & LPFC_STOP_IOCB_MBX) {
+                       phba->sli.ring[ringno].flag &= ~LPFC_STOP_IOCB_MBX;
                        /*
                         * Force update of the local copy of cmdGetInx
                         */
-                       pring->local_getidx = le32_to_cpu(pgp->cmdGetInx);
-                       lpfc_sli_resume_iocb(phba, pring);
+                       phba->sli.ring[ringno].local_getidx
+                               = le32_to_cpu(pgp->cmdGetInx);
+                       spin_lock_irq(phba->host->host_lock);
+                       lpfc_sli_resume_iocb(phba, &phba->sli.ring[ringno]);
+                       spin_unlock_irq(phba->host->host_lock);
                }
        }
 }
@@ -558,46 +488,67 @@ lpfc_sli_chk_mbx_command(uint8_t mbxCommand)
        }
        return (ret);
 }
-static int
+static void
+lpfc_sli_wake_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
+{
+       wait_queue_head_t *pdone_q;
+
+       /*
+        * If pdone_q is empty, the driver thread gave up waiting and
+        * continued running.
+        */
+       pdone_q = (wait_queue_head_t *) pmboxq->context1;
+       if (pdone_q)
+               wake_up_interruptible(pdone_q);
+       return;
+}
+
+void
+lpfc_sli_def_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
+{
+       struct lpfc_dmabuf *mp;
+       mp = (struct lpfc_dmabuf *) (pmb->context1);
+       if (mp) {
+               lpfc_mbuf_free(phba, mp->virt, mp->phys);
+               kfree(mp);
+       }
+       mempool_free( pmb, phba->mbox_mem_pool);
+       return;
+}
+
+int
 lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
 {
        MAILBOX_t *mbox;
        MAILBOX_t *pmbox;
        LPFC_MBOXQ_t *pmb;
-       struct lpfc_dmabuf *mp;
        struct lpfc_sli *psli;
-       int i;
-       unsigned long iflag;
+       int i, rc;
        uint32_t process_next;
 
-
        psli = &phba->sli;
        /* We should only get here if we are in SLI2 mode */
-       if (!(psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE)) {
+       if (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE)) {
                return (1);
        }
 
-       spin_lock_irqsave(phba->host->host_lock, iflag);
-
-       psli->slistat.mboxEvent++;
+       phba->sli.slistat.mbox_event++;
 
        /* Get a Mailbox buffer to setup mailbox commands for callback */
-       if ((pmb = psli->mbox_active)) {
+       if ((pmb = phba->sli.mbox_active)) {
                pmbox = &pmb->mb;
-               mbox = (MAILBOX_t *) psli->MBhostaddr;
+               mbox = (MAILBOX_t *) phba->sli.MBhostaddr;
 
                /* First check out the status word */
-               lpfc_sli_pcimem_bcopy((uint32_t *) mbox, (uint32_t *) pmbox,
-                                    sizeof (uint32_t));
+               lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof (uint32_t));
 
                /* Sanity check to ensure the host owns the mailbox */
                if (pmbox->mbxOwner != OWN_HOST) {
                        /* Lets try for a while */
                        for (i = 0; i < 10240; i++) {
                                /* First copy command data */
-                               lpfc_sli_pcimem_bcopy((uint32_t *) mbox,
-                                                    (uint32_t *) pmbox,
-                                                    sizeof (uint32_t));
+                               lpfc_sli_pcimem_bcopy(mbox, pmbox,
+                                                       sizeof (uint32_t));
                                if (pmbox->mbxOwner == OWN_HOST)
                                        goto mbout;
                        }
@@ -612,13 +563,15 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
                                        pmbox->mbxCommand,
                                        pmbox->mbxStatus);
 
-                       psli->sliinit.sli_flag |= LPFC_SLI_MBOX_ACTIVE;
-                       spin_unlock_irqrestore(phba->host->host_lock, iflag);
+                       spin_lock_irq(phba->host->host_lock);
+                       phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE;
+                       spin_unlock_irq(phba->host->host_lock);
                        return (1);
                }
 
              mbout:
-               del_timer_sync(&psli->mbox_tmo);
+               del_timer_sync(&phba->sli.mbox_tmo);
+               phba->work_hba_events &= ~WORKER_MBOX_TMO;
 
                /*
                 * It is a fatal error if unknown mbox command completion.
@@ -634,14 +587,14 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
                                phba->brd_no,
                                pmbox->mbxCommand);
                        phba->hba_state = LPFC_HBA_ERROR;
-                       spin_unlock_irqrestore(phba->host->host_lock, iflag);
-                       lpfc_handle_eratt(phba, HS_FFER3);
+                       phba->work_hs = HS_FFER3;
+                       lpfc_handle_eratt(phba);
                        return (0);
                }
 
-               psli->mbox_active = NULL;
+               phba->sli.mbox_active = NULL;
                if (pmbox->mbxStatus) {
-                       psli->slistat.mboxStatErr++;
+                       phba->sli.slistat.mbox_stat_err++;
                        if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) {
                                /* Mbox cmd cmpl error - RETRYing */
                                lpfc_printf_log(phba,
@@ -656,14 +609,12 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
                                        phba->hba_state);
                                pmbox->mbxStatus = 0;
                                pmbox->mbxOwner = OWN_HOST;
-                               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
-                               if (lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT)
-                                   == MBX_SUCCESS) {
-                                       spin_unlock_irqrestore(
-                                                      phba->host->host_lock,
-                                                      iflag);
+                               spin_lock_irq(phba->host->host_lock);
+                               phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+                               spin_unlock_irq(phba->host->host_lock);
+                               rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
+                               if (rc == MBX_SUCCESS)
                                        return (0);
-                               }
                        }
                }
 
@@ -687,46 +638,31 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
                                pmbox->un.varWords[7]);
 
                if (pmb->mbox_cmpl) {
-                       /* Copy entire mbox completion over buffer */
-                       lpfc_sli_pcimem_bcopy((uint32_t *) mbox,
-                                            (uint32_t *) pmbox,
-                                            (sizeof (uint32_t) *
-                                             (MAILBOX_CMD_WSIZE)));
-                       /* All mbox cmpls are posted to discovery tasklet */
-                       lpfc_discq_post_event(phba, pmb, NULL,
-                               LPFC_EVT_MBOX);
-               } else {
-                       mp = (struct lpfc_dmabuf *) (pmb->context1);
-                       if (mp) {
-                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                               kfree(mp);
-                       }
-                       mempool_free( pmb, phba->mbox_mem_pool);
+                       lpfc_sli_pcimem_bcopy(mbox, pmbox, MAILBOX_CMD_SIZE);
+                       pmb->mbox_cmpl(phba,pmb);
                }
        }
 
 
        do {
                process_next = 0;       /* by default don't loop */
-               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+               spin_lock_irq(phba->host->host_lock);
+               phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
 
                /* Process next mailbox command if there is one */
                if ((pmb = lpfc_mbox_get(phba))) {
-                       if (lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT) ==
-                           MBX_NOT_FINISHED) {
-                               mp = (struct lpfc_dmabuf *) (pmb->context1);
-                               if (mp) {
-                                       lpfc_mbuf_free(phba, mp->virt,
-                                                               mp->phys);
-                                       kfree(mp);
-                               }
-                               mempool_free( pmb, phba->mbox_mem_pool);
+                       spin_unlock_irq(phba->host->host_lock);
+                       rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
+                       if (rc == MBX_NOT_FINISHED) {
+                               pmb->mb.mbxStatus = MBX_NOT_FINISHED;
+                               pmb->mbox_cmpl(phba,pmb);
                                process_next = 1;
                                continue;       /* loop back */
                        }
                } else {
+                       spin_unlock_irq(phba->host->host_lock);
                        /* Turn on IOCB processing */
-                       for (i = 0; i < psli->sliinit.num_rings; i++) {
+                       for (i = 0; i < phba->sli.num_rings; i++) {
                                lpfc_sli_turn_on_ring(phba, i);
                        }
 
@@ -734,12 +670,14 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
                        while (!list_empty(&phba->freebufList)) {
                                struct lpfc_dmabuf *mp;
 
-                               mp = (struct lpfc_dmabuf *)
-                                       (phba->freebufList.next);
+                               mp = NULL;
+                               list_remove_head((&phba->freebufList),
+                                                mp,
+                                                struct lpfc_dmabuf,
+                                                list);
                                if (mp) {
                                        lpfc_mbuf_free(phba, mp->virt,
                                                       mp->phys);
-                                       list_del(&mp->list);
                                        kfree(mp);
                                }
                        }
@@ -747,23 +685,18 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
 
        } while (process_next);
 
-       spin_unlock_irqrestore(phba->host->host_lock, iflag);
        return (0);
 }
 static int
 lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                            struct lpfc_iocbq *saveq)
 {
-       struct lpfc_sli       * psli;
        IOCB_t           * irsp;
-       LPFC_RING_INIT_t * pringinit;
        WORD5            * w5p;
        uint32_t           Rctl, Type;
-       uint32_t           match, ringno, i;
+       uint32_t           match, i;
 
-       psli = &phba->sli;
        match = 0;
-       ringno = pring->ringno;
        irsp = &(saveq->iocb);
        if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX)
            || (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX)) {
@@ -775,46 +708,31 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                                 ulpWord[5]);
                Rctl = w5p->hcsw.Rctl;
                Type = w5p->hcsw.Type;
+
+               /* Firmware Workaround */
+               if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) &&
+                       (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX)) {
+                       Rctl = FC_ELS_REQ;
+                       Type = FC_ELS_DATA;
+                       w5p->hcsw.Rctl = Rctl;
+                       w5p->hcsw.Type = Type;
+               }
        }
        /* unSolicited Responses */
-       pringinit = &psli->sliinit.ringinit[ringno];
-       if (pringinit->prt[0].profile) {
-               /* If this ring has a profile set, just
-                  send it to prt[0] */
-               /* All unsol iocbs for LPFC_ELS_RING
-                * are posted to discovery tasklet.
-                */
-               if (ringno == LPFC_ELS_RING) {
-                       lpfc_discq_post_event(phba, (void *)&pringinit->prt[0],
-                       (void *)saveq,  LPFC_EVT_UNSOL_IOCB);
-               }
-               else {
-                       (pringinit->prt[0].
-                       lpfc_sli_rcv_unsol_event) (phba, pring, saveq);
-               }
+       if (pring->prt[0].profile) {
+               (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, saveq);
                match = 1;
        } else {
                /* We must search, based on rctl / type
                   for the right routine */
-               for (i = 0; i < pringinit->num_mask;
+               for (i = 0; i < pring->num_mask;
                     i++) {
-                       if ((pringinit->prt[i].rctl ==
+                       if ((pring->prt[i].rctl ==
                             Rctl)
-                           && (pringinit->prt[i].
+                           && (pring->prt[i].
                                type == Type)) {
-                               /* All unsol iocbs for LPFC_ELS_RING
-                                * are posted to discovery tasklet.
-                                */
-                               if (ringno == LPFC_ELS_RING) {
-                                       lpfc_discq_post_event(phba,
-                                       (void *)&pringinit->prt[i],
-                                       (void *)saveq,  LPFC_EVT_UNSOL_IOCB);
-                               }
-                               else {
-                                       (pringinit->prt[i].
-                                       lpfc_sli_rcv_unsol_event)
-                                       (phba, pring, saveq);
-                               }
+                               (pring->prt[i].lpfc_sli_rcv_unsol_event)
+                                       (phba, pring, saveq);
                                match = 1;
                                break;
                        }
@@ -830,14 +748,16 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                                "%d:0313 Ring %d handler: unexpected Rctl x%x "
                                "Type x%x received \n",
                                phba->brd_no,
-                               ringno,
+                               pring->ringno,
                                Rctl,
                                Type);
        }
        return(1);
 }
+
 static struct lpfc_iocbq *
-lpfc_search_txcmpl(struct lpfc_sli_ring * pring, struct lpfc_iocbq * prspiocb)
+lpfc_sli_txcmpl_ring_search_slow(struct lpfc_sli_ring * pring,
+                                struct lpfc_iocbq * prspiocb)
 {
        IOCB_t *icmd = NULL;
        IOCB_t *irsp = NULL;
@@ -863,57 +783,54 @@ lpfc_search_txcmpl(struct lpfc_sli_ring * pring, struct lpfc_iocbq * prspiocb)
 
        return (cmd_iocb);
 }
+
 static struct lpfc_iocbq *
-lpfc_sli_ringtxcmpl_get(struct lpfc_hba * phba,
+lpfc_sli_txcmpl_ring_iotag_lookup(struct lpfc_hba * phba,
                        struct lpfc_sli_ring * pring,
-                       struct lpfc_iocbq * prspiocb, uint32_t srch)
+                       struct lpfc_iocbq * prspiocb)
 {
-       struct list_head *dlp;
        IOCB_t *irsp = NULL;
-       struct lpfc_iocbq *cmd_iocb;
-       struct lpfc_sli *psli;
+       struct lpfc_iocbq *cmd_iocb = NULL;
        uint16_t iotag;
 
+       if (unlikely(pring->fast_lookup == NULL))
+               return NULL;
 
-       dlp = &pring->txcmplq;
-
-       if (pring->fast_lookup && (srch == 0)) {
-               /*
-                *  Use fast lookup based on iotag for completion
-                */
-               psli = &phba->sli;
-               irsp = &prspiocb->iocb;
-               iotag = irsp->ulpIoTag;
-               if (iotag < psli->sliinit.ringinit[pring->ringno].fast_iotag) {
-                       cmd_iocb = *(pring->fast_lookup + iotag);
-                       *(pring->fast_lookup + iotag) = NULL;
-                       if (cmd_iocb) {
-                               list_del(&cmd_iocb->list);
-                               pring->txcmplq_cnt--;
-                               return cmd_iocb;
-                       }
+       /* Use fast lookup based on iotag for completion */
+       irsp = &prspiocb->iocb;
+       iotag = irsp->ulpIoTag;
+       if (iotag < pring->fast_iotag) {
+               cmd_iocb = *(pring->fast_lookup + iotag);
+               *(pring->fast_lookup + iotag) = NULL;
+               if (cmd_iocb) {
+                       list_del(&cmd_iocb->list);
+                       pring->txcmplq_cnt--;
+                       return cmd_iocb;
                } else {
                        /*
-                        * Rsp ring <ringno> get: iotag <iotag> greater then
-                        *  configured max <fast_iotag> wd0 <irsp>
+                        * This is clearly an error.  A ring that uses iotags
+                        * should never have a interrupt for a completion that
+                        * is not on the ring.  Return NULL and log a error.
                         */
-                       lpfc_printf_log(phba,
-                                       KERN_ERR,
-                                       LOG_SLI,
-                                       "%d:0317 Rsp ring %d get: iotag x%x "
-                                       "greater then configured max x%x "
-                                       "wd0 x%x\n",
-                                       phba->brd_no,
-                                       pring->ringno, iotag,
-                                       psli->sliinit.ringinit[pring->ringno]
-                                       .fast_iotag,
-                                       *(((uint32_t *) irsp) + 7));
+                       lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+                               "%d:0327 Rsp ring %d error -  command "
+                               "completion for iotag x%x not found\n",
+                               phba->brd_no, pring->ringno, iotag);
+                       return NULL;
                }
        }
 
-       cmd_iocb = lpfc_search_txcmpl(pring, prspiocb);
-
-       return cmd_iocb;
+       /*
+        * Rsp ring <ringno> get: iotag <iotag> greater then
+        * configured max <fast_iotag> wd0 <irsp>.  This is an
+        * error.  Just return NULL.
+        */
+       lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+                       "%d:0317 Rsp ring %d get: iotag x%x greater then "
+                       "configured max x%x wd0 x%x\n",
+                       phba->brd_no, pring->ringno, iotag, pring->fast_iotag,
+                       *(((uint32_t *) irsp) + 7));
+       return NULL;
 }
 
 static int
@@ -921,32 +838,27 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
                          struct lpfc_iocbq *saveq)
 {
        struct lpfc_iocbq * cmdiocbp;
-       int            ringno, rc;
+       int rc = 1;
        unsigned long iflag;
 
-       rc = 1;
-       ringno = pring->ringno;
-       /* Solicited Responses */
-       /* Based on the iotag field, get the cmd IOCB
-          from the txcmplq */
+       /* Based on the iotag field, get the cmd IOCB from the txcmplq */
        spin_lock_irqsave(phba->host->host_lock, iflag);
-       if ((cmdiocbp =
-            lpfc_sli_ringtxcmpl_get(phba, pring, saveq,
-                                    0))) {
-               /* Call the specified completion
-                  routine */
+       cmdiocbp = lpfc_sli_txcmpl_ring_search_slow(pring, saveq);
+       if (cmdiocbp) {
                if (cmdiocbp->iocb_cmpl) {
-                       /* All iocb cmpls for LPFC_ELS_RING
-                        * are posted to discovery tasklet.
+                       /*
+                        * Post all ELS completions to the worker thread.
+                        * All other are passed to the completion callback.
                         */
-                       if (ringno == LPFC_ELS_RING) {
-                               lpfc_discq_post_event(phba, (void *)cmdiocbp,
-                                       (void *)saveq,  LPFC_EVT_SOL_IOCB);
+                       if (pring->ringno == LPFC_ELS_RING) {
+                               spin_unlock_irqrestore(phba->host->host_lock,
+                                                      iflag);
+                               (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq);
+                               spin_lock_irqsave(phba->host->host_lock, iflag);
                        }
                        else {
-                               if (cmdiocbp->iocb_flag & LPFC_IO_POLL) {
+                               if (cmdiocbp->iocb_flag & LPFC_IO_POLL)
                                        rc = 0;
-                               }
 
                                spin_unlock_irqrestore(phba->host->host_lock,
                                                       iflag);
@@ -954,23 +866,26 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
                                spin_lock_irqsave(phba->host->host_lock, iflag);
                        }
                } else {
-                       mempool_free( cmdiocbp, phba->iocb_mem_pool);
+                       list_add_tail(&cmdiocbp->list, &phba->lpfc_iocb_list);
                }
        } else {
-               /* Could not find the initiating command
-                * based of the response iotag.
-                * This is expected on ELS ring because of lpfc_els_abort().
+               /*
+                * Unknown initiating command based on the response iotag.
+                * This could be the case on the ELS ring because of
+                * lpfc_els_abort().
                 */
-               if (ringno != LPFC_ELS_RING) {
-                       /* Ring <ringno> handler: unexpected
-                          completion IoTag <IoTag> */
+               if (pring->ringno != LPFC_ELS_RING) {
+                       /*
+                        * Ring <ringno> handler: unexpected completion IoTag
+                        * <IoTag>
+                        */
                        lpfc_printf_log(phba,
                                KERN_WARNING,
                                LOG_SLI,
                                "%d:0322 Ring %d handler: unexpected "
                                "completion IoTag x%x Data: x%x x%x x%x x%x\n",
                                phba->brd_no,
-                               ringno,
+                               pring->ringno,
                                saveq->iocb.ulpIoTag,
                                saveq->iocb.ulpStatus,
                                saveq->iocb.un.ulpWord[4],
@@ -979,142 +894,300 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
                }
        }
        spin_unlock_irqrestore(phba->host->host_lock, iflag);
-       return(rc);
+       return rc;
 }
+
+/*
+ * This routine presumes LPFC_FCP_RING handling and doesn't bother
+ * to check it explicitly.
+ */
 static int
-lpfc_sli_handle_ring_event(struct lpfc_hba * phba,
-                          struct lpfc_sli_ring * pring, uint32_t mask)
+lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
+                               struct lpfc_sli_ring * pring, uint32_t mask)
 {
-       struct lpfc_sli       * psli;
-       IOCB_t           * entry;
-       IOCB_t           * irsp;
-       struct lpfc_iocbq     * rspiocbp, *next_iocb;
-       struct lpfc_iocbq     * cmdiocbp;
-       struct lpfc_iocbq     * saveq;
-       HGP              * hgp;
-       PGP              * pgp;
-       MAILBOX_t        * mbox;
-       uint32_t           status, free_saveq;
-       uint32_t           portRspPut, portRspMax;
-       int                ringno, loopcnt, rc;
-       uint8_t            type;
-       unsigned long      iflag;
-       void *to_slim;
-
-       psli   = &phba->sli;
-       ringno = pring->ringno;
-       irsp   = NULL;
-       rc     = 1;
+       IOCB_t *irsp = NULL;
+       struct lpfc_iocbq *cmdiocbq = NULL;
+       struct lpfc_iocbq rspiocbq;
+       PGP *pgp;
+       uint32_t status;
+       uint32_t portRspPut, portRspMax;
+       int rc = 1;
+       lpfc_iocb_type type;
+       unsigned long iflag;
+       uint32_t rsp_cmpl = 0;
+       void __iomem  *to_slim;
 
        spin_lock_irqsave(phba->host->host_lock, iflag);
-       psli->slistat.iocbEvent[ringno]++;
-
-       /* At this point we assume SLI-2 */
-       mbox = (MAILBOX_t *) psli->MBhostaddr;
-       pgp = (PGP *) & mbox->us.s2.port[ringno];
-       hgp = (HGP *) & mbox->us.s2.host[ringno];
+       pring->stats.iocb_event++;
 
-       /* portRspMax is the number of rsp ring entries for this specific
-          ring. */
-       portRspMax = psli->sliinit.ringinit[ringno].numRiocb;
+       /* The driver assumes SLI-2 mode */
+       pgp = (PGP *) &((MAILBOX_t *) phba->sli.MBhostaddr)
+               ->us.s2.port[pring->ringno];
 
-       rspiocbp = NULL;
-       loopcnt = 0;
-
-       /* Gather iocb entries off response ring.
-        * rspidx is the IOCB index of the next IOCB that the driver
-        * is going to process.
+       /*
+        * The next available response entry should never exceed the maximum
+        * entries.  If it does, treat it as an adapter hardware error.
         */
-       entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
+       portRspMax = pring->numRiocb;
        portRspPut = le32_to_cpu(pgp->rspPutInx);
-
-       if (portRspPut >= portRspMax) {
-
-               /* Ring <ringno> handler: portRspPut <portRspPut> is bigger then
-                  rsp ring <portRspMax> */
-               lpfc_printf_log(phba,
-                               KERN_ERR,
-                               LOG_SLI,
-                               "%d:0312 Ring %d handler: portRspPut %d "
-                               "is bigger then rsp ring %d\n",
-                               phba->brd_no,
-                               ringno, portRspPut, portRspMax);
+       if (unlikely(portRspPut >= portRspMax)) {
                /*
-                * Treat it as adapter hardware error.
+                * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
+                * rsp ring <portRspMax>
                 */
+               lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+                               "%d:0312 Ring %d handler: portRspPut %d "
+                               "is bigger then rsp ring %d\n",
+                               phba->brd_no, pring->ringno, portRspPut,
+                               portRspMax);
+
                phba->hba_state = LPFC_HBA_ERROR;
+
+               /* All error attention handlers are posted to worker thread */
+               phba->work_ha |= HA_ERATT;
+               phba->work_hs = HS_FFER3;
+               if (phba->work_wait)
+                       wake_up(phba->work_wait);
+
                spin_unlock_irqrestore(phba->host->host_lock, iflag);
-               lpfc_handle_eratt(phba, HS_FFER3);
-               return (1);
+               return 1;
        }
 
        rmb();
-
-       /* Get the next available response iocb.
-        * rspidx is the IOCB index of the next IOCB that the driver
-        * is going to process.
-        */
        while (pring->rspidx != portRspPut) {
-               /* get an iocb buffer to copy entry into */
-               if ((rspiocbp = mempool_alloc(phba->iocb_mem_pool,
-                                             GFP_ATOMIC)) == 0) {
+               irsp = (IOCB_t *) IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
+               type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK);
+               pring->stats.iocb_rsp++;
+               rsp_cmpl++;
+
+               if (unlikely(irsp->ulpStatus)) {
+                       /* Rsp ring <ringno> error: IOCB */
+                       lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
+                               "%d:0326 Rsp Ring %d error: IOCB Data: "
+                               "x%x x%x x%x x%x x%x x%x x%x x%x\n",
+                               phba->brd_no, pring->ringno,
+                               irsp->un.ulpWord[0], irsp->un.ulpWord[1],
+                               irsp->un.ulpWord[2], irsp->un.ulpWord[3],
+                               irsp->un.ulpWord[4], irsp->un.ulpWord[5],
+                               *(((uint32_t *) irsp) + 6),
+                               *(((uint32_t *) irsp) + 7));
+               }
+
+               switch (type) {
+               case LPFC_ABORT_IOCB:
+               case LPFC_SOL_IOCB:
+                       /*
+                        * Idle exchange closed via ABTS from port.  No iocb
+                        * resources need to be recovered.
+                        */
+                       if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
+                               printk(KERN_INFO "%s: IOCB cmd 0x%x processed. "
+                                      "Skipping completion\n", __FUNCTION__,
+                                      irsp->ulpCommand);
+                               break;
+                       }
+
+                       rspiocbq.iocb.un.ulpWord[4] = irsp->un.ulpWord[4];
+                       rspiocbq.iocb.ulpStatus = irsp->ulpStatus;
+                       rspiocbq.iocb.ulpContext = irsp->ulpContext;
+                       rspiocbq.iocb.ulpIoTag = irsp->ulpIoTag;
+                       cmdiocbq = lpfc_sli_txcmpl_ring_iotag_lookup(phba,
+                                                               pring,
+                                                               &rspiocbq);
+                       if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) {
+                               spin_unlock_irqrestore(
+                                      phba->host->host_lock, iflag);
+                               (cmdiocbq->iocb_cmpl)(phba, cmdiocbq,
+                                                     &rspiocbq);
+                               spin_lock_irqsave(phba->host->host_lock,
+                                                 iflag);
+                       }
+                       break;
+               default:
+                       if (irsp->ulpCommand == CMD_ADAPTER_MSG) {
+                               char adaptermsg[LPFC_MAX_ADPTMSG];
+                               memset(adaptermsg, 0, LPFC_MAX_ADPTMSG);
+                               memcpy(&adaptermsg[0], (uint8_t *) irsp,
+                                      MAX_MSG_DATA);
+                               dev_warn(&((phba->pcidev)->dev), "lpfc%d: %s",
+                                        phba->brd_no, adaptermsg);
+                       } else {
+                               /* Unknown IOCB command */
+                               lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+                                       "%d:0321 Unknown IOCB command "
+                                       "Data: x%x, x%x x%x x%x x%x\n",
+                                       phba->brd_no, type, irsp->ulpCommand,
+                                       irsp->ulpStatus, irsp->ulpIoTag,
+                                       irsp->ulpContext);
+                       }
                        break;
                }
 
-               lpfc_sli_pcimem_bcopy((uint32_t *) entry,
-                                     (uint32_t *) & rspiocbp->iocb,
-                                     sizeof (IOCB_t));
-               irsp = &rspiocbp->iocb;
-
-               /* bump iocb available response index */
-               if (++pring->rspidx >= portRspMax) {
+               /*
+                * The response IOCB has been processed.  Update the ring
+                * pointer in SLIM.  If the port response put pointer has not
+                * been updated, sync the pgp->rspPutInx and fetch the new port
+                * response put pointer.
+                */
+               if (++pring->rspidx >= portRspMax)
                        pring->rspidx = 0;
-               }
 
-               /* Let the HBA know what IOCB slot will be the next one the
-                * driver will read a response from.
-                */
-               to_slim = (uint8_t *) phba->MBslimaddr +
-                       (SLIMOFF + (ringno * 2) + 1) * 4;
-               writeb( pring->rspidx, to_slim);
+               to_slim = phba->MBslimaddr +
+                       (SLIMOFF + (pring->ringno * 2) + 1) * 4;
+               writeb(pring->rspidx, to_slim);
 
-               /* chain all iocb entries until LE is set */
-               if (list_empty(&(pring->iocb_continueq))) {
-                       list_add(&rspiocbp->list, &(pring->iocb_continueq));
-               } else {
-                       list_add_tail(&rspiocbp->list,
-                                     &(pring->iocb_continueq));
-               }
-               pring->iocb_continueq_cnt++;
+               if (pring->rspidx == portRspPut)
+                       portRspPut = le32_to_cpu(pgp->rspPutInx);
+       }
 
-               /*
-                * When the ulpLe field is set, the entire Command has been
-                * received. Start by getting a pointer to the first iocb entry
-                * in the chain.
-                */
-               if (irsp->ulpLe) {
-                       /*
-                        * By default, the driver expects to free all resources
-                        * associated with this iocb completion.
-                        */
-                       free_saveq = 1;
-                       saveq = list_entry(pring->iocb_continueq.next,
-                                          struct lpfc_iocbq, list);
-                       irsp = &(saveq->iocb);
-                       list_del_init(&pring->iocb_continueq);
-                       pring->iocb_continueq_cnt = 0;
+       if ((rsp_cmpl > 0) && (mask & HA_R0RE_REQ)) {
+               pring->stats.iocb_rsp_full++;
+               status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4));
+               writel(status, phba->CAregaddr);
+               readl(phba->CAregaddr);
+       }
+       if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) {
+               pring->flag &= ~LPFC_CALL_RING_AVAILABLE;
+               pring->stats.iocb_cmd_empty++;
 
-                       psli->slistat.iocbRsp[ringno]++;
+               /* Force update of the local copy of cmdGetInx */
+               pring->local_getidx = le32_to_cpu(pgp->cmdGetInx);
+               lpfc_sli_resume_iocb(phba, pring);
+
+               if ((pring->lpfc_sli_cmd_available))
+                       (pring->lpfc_sli_cmd_available) (phba, pring);
+
+       }
+
+       spin_unlock_irqrestore(phba->host->host_lock, iflag);
+       return rc;
+}
+
+
+int
+lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
+                          struct lpfc_sli_ring * pring, uint32_t mask)
+{
+       IOCB_t *entry;
+       IOCB_t *irsp = NULL;
+       struct lpfc_iocbq *rspiocbp = NULL;
+       struct lpfc_iocbq *next_iocb;
+       struct lpfc_iocbq *cmdiocbp;
+       struct lpfc_iocbq *saveq;
+       struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;
+       HGP *hgp;
+       PGP *pgp;
+       MAILBOX_t *mbox;
+       uint8_t iocb_cmd_type;
+       lpfc_iocb_type type;
+       uint32_t status, free_saveq;
+       uint32_t portRspPut, portRspMax;
+       int rc = 1;
+       unsigned long iflag;
+       void __iomem  *to_slim;
+
+       spin_lock_irqsave(phba->host->host_lock, iflag);
+       pring->stats.iocb_event++;
+
+       /* The driver assumes SLI-2 mode */
+       mbox = (MAILBOX_t *) phba->sli.MBhostaddr;
+       pgp = (PGP *) & mbox->us.s2.port[pring->ringno];
+       hgp = (HGP *) & mbox->us.s2.host[pring->ringno];
+
+       /*
+        * The next available response entry should never exceed the maximum
+        * entries.  If it does, treat it as an adapter hardware error.
+        */
+       portRspMax = pring->numRiocb;
+       portRspPut = le32_to_cpu(pgp->rspPutInx);
+       if (portRspPut >= portRspMax) {
+               /*
+                * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
+                * rsp ring <portRspMax>
+                */
+               lpfc_printf_log(phba,
+                               KERN_ERR,
+                               LOG_SLI,
+                               "%d:0312 Ring %d handler: portRspPut %d "
+                               "is bigger then rsp ring %d\n",
+                               phba->brd_no,
+                               pring->ringno, portRspPut, portRspMax);
+
+               phba->hba_state = LPFC_HBA_ERROR;
+               spin_unlock_irqrestore(phba->host->host_lock, iflag);
+
+               phba->work_hs = HS_FFER3;
+               lpfc_handle_eratt(phba);
+
+               return 1;
+       }
+
+       rmb();
+       lpfc_iocb_list = &phba->lpfc_iocb_list;
+       while (pring->rspidx != portRspPut) {
+               /*
+                * Build a completion list and call the appropriate handler.
+                * The process is to get the next available response iocb, get
+                * a free iocb from the list, copy the response data into the
+                * free iocb, insert to the continuation list, and update the
+                * next response index to slim.  This process makes response
+                * iocb's in the ring available to DMA as fast as possible but
+                * pays a penalty for a copy operation.  Since the iocb is
+                * only 32 bytes, this penalty is considered small relative to
+                * the PCI reads for register values and a slim write.  When
+                * the ulpLe field is set, the entire Command has been
+                * received.
+                */
+               entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
+               list_remove_head(lpfc_iocb_list, rspiocbp, struct lpfc_iocbq,
+                                list);
+               if (rspiocbp == NULL) {
+                       printk(KERN_ERR "%s: out of buffers! Failing "
+                              "completion.\n", __FUNCTION__);
+                       break;
+               }
+
+               lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, sizeof (IOCB_t));
+               irsp = &rspiocbp->iocb;
+
+               if (++pring->rspidx >= portRspMax)
+                       pring->rspidx = 0;
+
+               to_slim = phba->MBslimaddr + (SLIMOFF + (pring->ringno * 2)
+                                             + 1) * 4;
+               writeb(pring->rspidx, to_slim);
+
+               if (list_empty(&(pring->iocb_continueq))) {
+                       list_add(&rspiocbp->list, &(pring->iocb_continueq));
+               } else {
+                       list_add_tail(&rspiocbp->list,
+                                     &(pring->iocb_continueq));
+               }
+
+               pring->iocb_continueq_cnt++;
+               if (irsp->ulpLe) {
+                       /*
+                        * By default, the driver expects to free all resources
+                        * associated with this iocb completion.
+                        */
+                       free_saveq = 1;
+                       saveq = list_get_first(&pring->iocb_continueq,
+                                              struct lpfc_iocbq, list);
+                       irsp = &(saveq->iocb);
+                       list_del_init(&pring->iocb_continueq);
+                       pring->iocb_continueq_cnt = 0;
+
+                       pring->stats.iocb_rsp++;
 
-                       if(irsp->ulpStatus) {
+                       if (irsp->ulpStatus) {
                                /* Rsp ring <ringno> error: IOCB */
                                lpfc_printf_log(phba,
                                        KERN_WARNING,
                                        LOG_SLI,
-                                       "%d:0324 Rsp Ring %d error: IOCB Data: "
+                                       "%d:0328 Rsp Ring %d error: IOCB Data: "
                                        "x%x x%x x%x x%x x%x x%x x%x x%x\n",
                                        phba->brd_no,
-                                       ringno,
+                                       pring->ringno,
                                        irsp->un.ulpWord[0],
                                        irsp->un.ulpWord[1],
                                        irsp->un.ulpWord[2],
@@ -1125,53 +1198,31 @@ lpfc_sli_handle_ring_event(struct lpfc_hba * phba,
                                        *(((uint32_t *) irsp) + 7));
                        }
 
-                       /* Determine if IOCB command is a solicited or
-                          unsolicited event */
-                       type =
-                           lpfc_sli_iocb_cmd_type[(irsp->
-                                                   ulpCommand &
-                                                   CMD_IOCB_MASK)];
+                       /*
+                        * Fetch the IOCB command type and call the correct
+                        * completion routine.  Solicited and Unsolicited
+                        * IOCBs on the ELS ring get freed back to the
+                        * lpfc_iocb_list by the discovery kernel thread.
+                        */
+                       iocb_cmd_type = irsp->ulpCommand & CMD_IOCB_MASK;
+                       type = lpfc_sli_iocb_cmd_type(iocb_cmd_type);
                        if (type == LPFC_SOL_IOCB) {
                                spin_unlock_irqrestore(phba->host->host_lock,
                                                       iflag);
                                rc = lpfc_sli_process_sol_iocb(phba, pring,
                                        saveq);
                                spin_lock_irqsave(phba->host->host_lock, iflag);
-                               /*
-                                * If this solicted completion is an ELS
-                                * command, don't free the resources now because
-                                * the discoverytasklet does later.
-                                */
-                               if (pring->ringno == LPFC_ELS_RING)
-                                       free_saveq = 0;
-                               else
-                                       free_saveq = 1;
-
                        } else if (type == LPFC_UNSOL_IOCB) {
                                spin_unlock_irqrestore(phba->host->host_lock,
                                                       iflag);
                                rc = lpfc_sli_process_unsol_iocb(phba, pring,
                                        saveq);
                                spin_lock_irqsave(phba->host->host_lock, iflag);
-
-                               /*
-                                * If this unsolicted completion is an ELS
-                                * command, don't free the resources now because
-                                * the discoverytasklet does later.
-                                */
-                               if (pring->ringno == LPFC_ELS_RING)
-                                       free_saveq = 0;
-                               else
-                                       free_saveq = 1;
-
                        } else if (type == LPFC_ABORT_IOCB) {
-                               /* Solicited ABORT Responses */
-                               /* Based on the iotag field, get the cmd IOCB
-                                  from the txcmplq */
                                if ((irsp->ulpCommand != CMD_XRI_ABORTED_CX) &&
                                    ((cmdiocbp =
-                                     lpfc_sli_ringtxcmpl_get(phba, pring,
-                                                             saveq, 0)))) {
+                                     lpfc_sli_txcmpl_ring_search_slow(pring,
+                                               saveq)))) {
                                        /* Call the specified completion
                                           routine */
                                        if (cmdiocbp->iocb_cmpl) {
@@ -1184,8 +1235,8 @@ lpfc_sli_handle_ring_event(struct lpfc_hba * phba,
                                                          phba->host->host_lock,
                                                          iflag);
                                        } else {
-                                               mempool_free(cmdiocbp,
-                                                    phba->iocb_mem_pool);
+                                               list_add_tail(&cmdiocbp->list,
+                                                               lpfc_iocb_list);
                                        }
                                }
                        } else if (type == LPFC_UNKNOWN_IOCB) {
@@ -1216,182 +1267,82 @@ lpfc_sli_handle_ring_event(struct lpfc_hba * phba,
                        }
 
                        if (free_saveq) {
-                               /*
-                                * Free up iocb buffer chain for command just
-                                * processed
-                                */
-                               if (!list_empty(&pring->iocb_continueq)) {
+                               if (!list_empty(&saveq->list)) {
                                        list_for_each_entry_safe(rspiocbp,
-                                                next_iocb,
-                                                &pring->iocb_continueq, list) {
-                                       list_del_init(&rspiocbp->list);
-                                       mempool_free(rspiocbp,
-                                                    phba->iocb_mem_pool);
+                                                                next_iocb,
+                                                                &saveq->list,
+                                                                list) {
+                                               list_add_tail(&rspiocbp->list,
+                                                             lpfc_iocb_list);
                                        }
                                }
-                       mempool_free( saveq, phba->iocb_mem_pool);
+
+                               list_add_tail(&saveq->list, lpfc_iocb_list);
                        }
                }
 
-               /* Entire Command has been received */
-               entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
-
-               /* If the port response put pointer has not been updated, sync
+               /*
+                * If the port response put pointer has not been updated, sync
                 * the pgp->rspPutInx in the MAILBOX_tand fetch the new port
                 * response put pointer.
                 */
                if (pring->rspidx == portRspPut) {
                        portRspPut = le32_to_cpu(pgp->rspPutInx);
                }
-       }                       /* while (pring->rspidx != portRspPut) */
+       } /* while (pring->rspidx != portRspPut) */
 
        if ((rspiocbp != 0) && (mask & HA_R0RE_REQ)) {
                /* At least one response entry has been freed */
-               psli->slistat.iocbRspFull[ringno]++;
+               pring->stats.iocb_rsp_full++;
                /* SET RxRE_RSP in Chip Att register */
-               status = ((CA_R0ATT | CA_R0RE_RSP) << (ringno * 4));
+               status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4));
                writel(status, phba->CAregaddr);
                readl(phba->CAregaddr); /* flush */
        }
        if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) {
                pring->flag &= ~LPFC_CALL_RING_AVAILABLE;
-               psli->slistat.iocbCmdEmpty[ringno]++;
-               /*
-                * Force update of the local copy of cmdGetInx
-                */
+               pring->stats.iocb_cmd_empty++;
+
+               /* Force update of the local copy of cmdGetInx */
                pring->local_getidx = le32_to_cpu(pgp->cmdGetInx);
                lpfc_sli_resume_iocb(phba, pring);
-               
-               if ((psli->sliinit.ringinit[ringno].lpfc_sli_cmd_available))
-                       (psli->sliinit.ringinit[ringno].
-                        lpfc_sli_cmd_available) (phba, pring);
+
+               if ((pring->lpfc_sli_cmd_available))
+                       (pring->lpfc_sli_cmd_available) (phba, pring);
 
        }
 
        spin_unlock_irqrestore(phba->host->host_lock, iflag);
-       return (rc);
+       return rc;
 }
 
-static uint32_t
-lpfc_intr_prep(struct lpfc_hba * phba)
-{
-       uint32_t ha_copy;
-
-       /* Ignore all interrupts during initialization. */
-       if (phba->hba_state < LPFC_LINK_DOWN)
-               return (0);
-
-       /* Read host attention register to determine interrupt source */
-       ha_copy = readl(phba->HAregaddr);
-
-       /* Clear Attention Sources, except ERATT (to preserve status) & LATT
-        *    (ha_copy & ~(HA_ERATT | HA_LATT));
-        */
-       writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr);
-       readl(phba->HAregaddr); /* flush */
-       return (ha_copy);
-}                              /* lpfc_intr_prep */
-
 int
-lpfc_sli_intr(struct lpfc_hba * phba)
-{
-       struct lpfc_sli *psli;
-       struct lpfc_sli_ring *pring;
-       uint32_t ha_copy, status;
-       int i;
-
-       psli = &phba->sli;
-       psli->slistat.sliIntr++;
-
-       /*
-        * Call the HBA to see if it is interrupting.  If not, don't claim
-        * the interrupt
-        */
-       ha_copy = lpfc_intr_prep(phba);
-       if (!ha_copy) {
-               return (1);
-       }
-
-       if (ha_copy & HA_ERATT) {
-               /*
-                * There was a link/board error.  Read the status register to
-                * retrieve the error event and process it.
-                */
-               psli->slistat.errAttnEvent++;
-               status = readl(phba->HSregaddr);
-
-               /* Clear Chip error bit */
-               writel(HA_ERATT, phba->HAregaddr);
-               readl(phba->HAregaddr); /* flush */
-
-               lpfc_handle_eratt(phba, status);
-               return (0);
-       }
-
-       if (ha_copy & HA_MBATT) {
-               /* There was a Mailbox event. */
-               lpfc_sli_handle_mb_event(phba);
-       }
-
-       if (ha_copy & HA_LATT) {
-               /*
-                * There was a link attention event.  Provided the driver is in
-                * a state to handle link events, handle this event.
-                */
-               if (psli->sliinit.sli_flag & LPFC_PROCESS_LA) {
-                       lpfc_handle_latt(phba);
-               }
-       }
-
-       /* Process all events on each ring */
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
-               pring = &psli->ring[i];
-               if ((ha_copy & HA_RXATT)
-                   || (pring->flag & LPFC_DEFERRED_RING_EVENT)) {
-                       if (pring->flag & LPFC_STOP_IOCB_MASK) {
-                               pring->flag |= LPFC_DEFERRED_RING_EVENT;
-                       } else {
-                               lpfc_sli_handle_ring_event(phba, pring,
-                                                          (ha_copy &
-                                                           HA_RXMASK));
-                               pring->flag &= ~LPFC_DEFERRED_RING_EVENT;
-                       }
-               }
-               ha_copy = (ha_copy >> 4);
-       }
-
-       return (0);
-}
-
-static int
-lpfc_sli_abort_iocb_ring(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
-                        uint32_t flag)
+lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
 {
-       struct lpfc_sli *psli;
        struct lpfc_iocbq *iocb, *next_iocb;
-       struct lpfc_iocbq *abtsiocbp;
        IOCB_t *icmd = NULL, *cmd = NULL;
        int errcnt;
        uint16_t iotag;
 
-       psli = &phba->sli;
        errcnt = 0;
 
        /* Error everything on txq and txcmplq
         * First do the txq.
         */
+       spin_lock_irq(phba->host->host_lock);
        list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
                list_del_init(&iocb->list);
                if (iocb->iocb_cmpl) {
                        icmd = &iocb->iocb;
                        icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
                        icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
+                       spin_unlock_irq(phba->host->host_lock);
                        (iocb->iocb_cmpl) (phba, iocb, iocb);
+                       spin_lock_irq(phba->host->host_lock);
                } else {
-                       mempool_free( iocb, phba->iocb_mem_pool);
+                       list_add_tail(&iocb->list, &phba->lpfc_iocb_list);
                }
        }
-
        pring->txq_cnt = 0;
        INIT_LIST_HEAD(&(pring->txq));
 
@@ -1399,89 +1350,55 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
        list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
                cmd = &iocb->iocb;
 
-               if (flag == LPFC_SLI_ABORT_IMED) {
-                       /*
-                        * Imediate abort of IOCB, clear fast_lookup entry,
-                        * if any, deque and call compl
-                        */
-                       iotag = cmd->ulpIoTag;
-                       if (pring->fast_lookup &&
-                           iotag &&
-                           (iotag <
-                            psli->sliinit.ringinit[pring->ringno].fast_iotag))
-                               *(pring->fast_lookup + iotag) = NULL;
-
-                       list_del_init(&iocb->list);
-                       pring->txcmplq_cnt--;
-
-                       if (iocb->iocb_cmpl) {
-                               cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
-                               cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
-                               (iocb->iocb_cmpl) (phba, iocb, iocb);
-                       } else {
-                               mempool_free( iocb, phba->iocb_mem_pool);
-                       }
-                       continue;
-               }
-
-               /* issue ABTS for this IOCB based on iotag */
-
-               if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool,
-                                              GFP_ATOMIC)) == 0) {
-                       errcnt++;
-                       continue;
-               }
-               memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-               icmd = &abtsiocbp->iocb;
+               /*
+                * Imediate abort of IOCB, clear fast_lookup entry,
+                * if any, deque and call compl
+                */
+               iotag = cmd->ulpIoTag;
+               if (iotag && pring->fast_lookup &&
+                   (iotag < pring->fast_iotag))
+                       pring->fast_lookup[iotag] = NULL;
 
-               icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
-               icmd->un.acxri.abortContextTag = cmd->ulpContext;
-               icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
+               list_del_init(&iocb->list);
+               pring->txcmplq_cnt--;
 
-               icmd->ulpLe = 1;
-               icmd->ulpClass = cmd->ulpClass;
-               if (phba->hba_state >= LPFC_LINK_UP) {
-                       icmd->ulpCommand = CMD_ABORT_XRI_CN;
+               if (iocb->iocb_cmpl) {
+                       cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
+                       cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
+                       spin_unlock_irq(phba->host->host_lock);
+                       (iocb->iocb_cmpl) (phba, iocb, iocb);
+                       spin_lock_irq(phba->host->host_lock);
                } else {
-                       icmd->ulpCommand = CMD_CLOSE_XRI_CN;
-
-               }
-
-               if (lpfc_sli_issue_iocb
-                   (phba, pring, abtsiocbp, 0) == IOCB_ERROR) {
-                       mempool_free(abtsiocbp, phba->iocb_mem_pool);
-                       errcnt++;
-                       continue;
+                       list_add_tail(&iocb->list, &phba->lpfc_iocb_list);
                }
-               /* The rsp ring completion will remove IOCB from txcmplq when
-                * abort is read by HBA.
-                */
        }
 
-       if (flag == LPFC_SLI_ABORT_IMED) {
-               INIT_LIST_HEAD(&(pring->txcmplq));
-               pring->txcmplq_cnt = 0;
-       }
+       INIT_LIST_HEAD(&pring->txcmplq);
+       pring->txcmplq_cnt = 0;
+       spin_unlock_irq(phba->host->host_lock);
 
-       return (errcnt);
+       return errcnt;
 }
 
-int
-lpfc_sli_brdreset(struct lpfc_hba * phba)
+/******************************************************************************
+* lpfc_sli_send_reset
+*
+* Note: After returning from this function, the HBA cannot be accessed for
+* 1 ms. Since we do not wish to delay in interrupt context, it is the
+* responsibility of the caller to perform the mdelay(1) and flush via readl().
+******************************************************************************/
+static int
+lpfc_sli_send_reset(struct lpfc_hba * phba, uint16_t skip_post)
 {
        MAILBOX_t *swpmb;
-       struct lpfc_sli *psli;
-       struct lpfc_sli_ring *pring;
-       uint16_t cfg_value, skip_post;
        volatile uint32_t word0;
-       int i;
-       void *to_slim;
-       struct lpfc_dmabuf *mp, *next_mp;
+       void __iomem *to_slim;
+       unsigned long flags = 0;
 
-       psli = &phba->sli;
+       spin_lock_irqsave(phba->host->host_lock, flags);
 
        /* A board reset must use REAL SLIM. */
-       psli->sliinit.sli_flag &= ~LPFC_SLI2_ACTIVE;
+       phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE;
 
        word0 = 0;
        swpmb = (MAILBOX_t *) & word0;
@@ -1493,55 +1410,68 @@ lpfc_sli_brdreset(struct lpfc_hba * phba)
        readl(to_slim); /* flush */
 
        /* Only skip post after fc_ffinit is completed */
-       if (phba->hba_state) {
-               skip_post = 1;
+       if (skip_post) {
                word0 = 1;      /* This is really setting up word1 */
        } else {
-               skip_post = 0;
                word0 = 0;      /* This is really setting up word1 */
        }
-       to_slim = (uint8_t *) phba->MBslimaddr + sizeof (uint32_t);
+       to_slim = phba->MBslimaddr + sizeof (uint32_t);
        writel(*(uint32_t *) swpmb, to_slim);
        readl(to_slim); /* flush */
 
-       /* Reset HBA */
-       lpfc_printf_log(phba,
-               KERN_INFO,
-               LOG_SLI,
-               "%d:0325 Reset HBA Data: x%x x%x\n",
-               phba->brd_no,
-               phba->hba_state,
-               psli->sliinit.sli_flag);
-
-       /* Turn off SERR, PERR in PCI cmd register */
-       phba->hba_state = LPFC_INIT_START;
-
-       /* perform board reset */
-       phba->fc_eventTag = 0;
-       phba->fc_myDID = 0;
-       phba->fc_prevDID = 0;
-
        /* Turn off parity checking and serr during the physical reset */
-       pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value);
+       pci_read_config_word(phba->pcidev, PCI_COMMAND, &phba->pci_cfg_value);
        pci_write_config_word(phba->pcidev, PCI_COMMAND,
-                             (cfg_value &
+                             (phba->pci_cfg_value &
                               ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR)));
 
-       /* Now toggle INITFF bit in the Host Control Register */
        writel(HC_INITFF, phba->HCregaddr);
+
+       phba->hba_state = LPFC_INIT_START;
+       spin_unlock_irqrestore(phba->host->host_lock, flags);
+
+       return 0;
+}
+
+static int
+lpfc_sli_brdreset(struct lpfc_hba * phba, uint16_t skip_post)
+{
+       struct lpfc_sli_ring *pring;
+       int i;
+       struct lpfc_dmabuf *mp, *next_mp;
+       unsigned long flags = 0;
+
+       lpfc_sli_send_reset(phba, skip_post);
        mdelay(1);
+
+       spin_lock_irqsave(phba->host->host_lock, flags);
+       /* Risk the write on flush case ie no delay after the readl */
        readl(phba->HCregaddr); /* flush */
+       /* Now toggle INITFF bit set by lpfc_sli_send_reset */
        writel(0, phba->HCregaddr);
        readl(phba->HCregaddr); /* flush */
 
        /* Restore PCI cmd register */
+       pci_write_config_word(phba->pcidev, PCI_COMMAND, phba->pci_cfg_value);
 
-       pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value);
-       phba->hba_state = LPFC_INIT_START;
+       /* perform board reset */
+       phba->fc_eventTag = 0;
+       phba->fc_myDID = 0;
+       phba->fc_prevDID = Mask_DID;
+
+       /* Reset HBA */
+       lpfc_printf_log(phba,
+               KERN_INFO,
+               LOG_SLI,
+               "%d:0325 Reset HBA Data: x%x x%x x%x\n",
+               phba->brd_no,
+               phba->hba_state,
+               phba->sli.sli_flag,
+               skip_post);
 
        /* Initialize relevant SLI info */
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
-               pring = &psli->ring[i];
+       for (i = 0; i < phba->sli.num_rings; i++) {
+               pring = &phba->sli.ring[i];
                pring->flag = 0;
                pring->rspidx = 0;
                pring->next_cmdidx  = 0;
@@ -1549,6 +1479,7 @@ lpfc_sli_brdreset(struct lpfc_hba * phba)
                pring->cmdidx = 0;
                pring->missbufcnt = 0;
        }
+       spin_unlock_irqrestore(phba->host->host_lock, flags);
 
        if (skip_post) {
                mdelay(100);
@@ -1556,69 +1487,28 @@ lpfc_sli_brdreset(struct lpfc_hba * phba)
                mdelay(2000);
        }
 
+       spin_lock_irqsave(phba->host->host_lock, flags);
        /* Cleanup preposted buffers on the ELS ring */
-       pring = &psli->ring[LPFC_ELS_RING];
+       pring = &phba->sli.ring[LPFC_ELS_RING];
        list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) {
                list_del(&mp->list);
                pring->postbufq_cnt--;
                lpfc_mbuf_free(phba, mp->virt, mp->phys);
                kfree(mp);
        }
+       spin_unlock_irqrestore(phba->host->host_lock, flags);
 
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
-               pring = &psli->ring[i];
-               lpfc_sli_abort_iocb_ring(phba, pring, LPFC_SLI_ABORT_IMED);
-       }
-
-       return (0);
-}
+       for (i = 0; i < phba->sli.num_rings; i++)
+               lpfc_sli_abort_iocb_ring(phba, &phba->sli.ring[i]);
 
-static void
-lpfc_setup_slim_access(struct lpfc_hba *phba)
-{
-       phba->MBslimaddr = phba->slim_memmap_p;
-       phba->HAregaddr = (uint32_t *) (phba->ctrl_regs_memmap_p) +
-               HA_REG_OFFSET;
-       phba->HCregaddr = (uint32_t *) (phba->ctrl_regs_memmap_p) +
-               HC_REG_OFFSET;
-       phba->CAregaddr = (uint32_t *) (phba->ctrl_regs_memmap_p) +
-               CA_REG_OFFSET;
-       phba->HSregaddr = (uint32_t *) (phba->ctrl_regs_memmap_p) +
-               HS_REG_OFFSET;
-       return;
+       return 0;
 }
 
-int
-lpfc_sli_hba_setup(struct lpfc_hba * phba)
+static int
+lpfc_sli_chipset_init(struct lpfc_hba *phba)
 {
-       struct lpfc_sli *psli;
-       LPFC_MBOXQ_t *pmb;
-       int read_rev_reset, i, rc;
-       uint32_t status;
-
-       psli = &phba->sli;
+       uint32_t status, i = 0;
 
-       /* Setep SLI interface for HBA register and HBA SLIM access */
-       lpfc_setup_slim_access(phba);
-
-       /* Set board state to initialization started */
-       phba->hba_state = LPFC_INIT_START;
-       read_rev_reset = 0;
-
-       /* On some platforms/OS's, the driver can't rely on the state the
-        * adapter may be in.  For this reason, the driver is allowed to reset
-        * the HBA before initialization.
-        */
-       if (lpfc_sli_reset_on_init) {
-               phba->hba_state = 0;    /* Don't skip post */
-               lpfc_sli_brdreset(phba);
-               phba->hba_state = LPFC_INIT_START;
-
-               /* Sleep for 2.5 sec */
-               msleep(2500);   
-       }
-
-top:
        /* Read the HBA Host Status Register */
        status = readl(phba->HSregaddr);
 
@@ -1669,9 +1559,7 @@ top:
                }
 
                if (i == 15) {
-                       phba->hba_state = 0;    /* Don't skip post */
-                       lpfc_sli_brdreset(phba);
-                       phba->hba_state = LPFC_INIT_START;
+                       lpfc_sli_brdreset(phba, 0);
                }
                /* Read the HBA Host Status Register */
                status = readl(phba->HSregaddr);
@@ -1699,136 +1587,116 @@ top:
        /* setup host attn register */
        writel(0xffffffff, phba->HAregaddr);
        readl(phba->HAregaddr); /* flush */
+       return 0;
+}
+
+int
+lpfc_sli_hba_setup(struct lpfc_hba * phba)
+{
+       LPFC_MBOXQ_t *pmb;
+       uint32_t resetcount = 0, rc = 0, done = 0;
 
-       /* Get a Mailbox buffer to setup mailbox commands for HBA
-          initialization */
-       if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
-                                                 GFP_ATOMIC)) == 0) {
+       pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+       if (!pmb) {
                phba->hba_state = LPFC_HBA_ERROR;
                return -ENOMEM;
        }
 
-       /* Call pre CONFIG_PORT mailbox command initialization.  A value of 0
+       while (resetcount < 2 && !done) {
+               phba->hba_state = 0;
+               lpfc_sli_brdreset(phba, 0);
+               msleep(2500);
+               rc = lpfc_sli_chipset_init(phba);
+               if (rc)
+                       break;
+
+               resetcount++;
+
+       /* Call pre CONFIG_PORT mailbox command initialization.  A value of 0
         * means the call was successful.  Any other nonzero value is a failure,
         * but if ERESTART is returned, the driver may reset the HBA and try
         * again.
         */
-       if ((rc = lpfc_config_port_prep(phba))) {
-               if ((rc == -ERESTART) && (read_rev_reset == 0)) {
-                       mempool_free( pmb, phba->mbox_mem_pool);
-                       phba->hba_state = 0;    /* Don't skip post */
-                       lpfc_sli_brdreset(phba);
-                       phba->hba_state = LPFC_INIT_START;
-                       msleep(500);
-                       read_rev_reset = 1;
-                       goto top;
+               rc = lpfc_config_port_prep(phba);
+               if (rc == -ERESTART) {
+                       phba->hba_state = 0;
+                       continue;
+               } else if (rc) {
+                       break;
                }
-               phba->hba_state = LPFC_HBA_ERROR;
-               mempool_free( pmb, phba->mbox_mem_pool);
-               return -ENXIO;
-       }
 
-       /* Setup and issue mailbox CONFIG_PORT command */
-       phba->hba_state = LPFC_INIT_MBX_CMDS;
-       lpfc_config_port(phba, pmb);
-       if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
-               /* Adapter failed to init, mbxCmd <cmd> CONFIG_PORT,
-                  mbxStatus <status> */
-               lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+               phba->hba_state = LPFC_INIT_MBX_CMDS;
+               lpfc_config_port(phba, pmb);
+               rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
+               if (rc == MBX_SUCCESS)
+                       done = 1;
+               else {
+                       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
                                "%d:0442 Adapter failed to init, mbxCmd x%x "
                                "CONFIG_PORT, mbxStatus x%x Data: x%x\n",
                                phba->brd_no, pmb->mb.mbxCommand,
                                pmb->mb.mbxStatus, 0);
-
-               /* This clause gives the config_port call is given multiple
-                  chances to succeed. */
-               if (read_rev_reset == 0) {
-                       mempool_free( pmb, phba->mbox_mem_pool);
-                       phba->hba_state = 0;    /* Don't skip post */
-                       lpfc_sli_brdreset(phba);
-                       phba->hba_state = LPFC_INIT_START;
-                       msleep(2500);
-                       read_rev_reset = 1;
-                       goto top;
+                       phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE;
                }
-
-               psli->sliinit.sli_flag &= ~LPFC_SLI2_ACTIVE;
-               phba->hba_state = LPFC_HBA_ERROR;
-               mempool_free( pmb, phba->mbox_mem_pool);
-               return -ENXIO;
        }
+       if (!done)
+               goto lpfc_sli_hba_setup_error;
 
-       if ((rc = lpfc_sli_ring_map(phba))) {
-               phba->hba_state = LPFC_HBA_ERROR;
-               mempool_free( pmb, phba->mbox_mem_pool);
-               return -ENXIO;
-       }
-       psli->sliinit.sli_flag |= LPFC_PROCESS_LA;
-
-       /* Call post CONFIG_PORT mailbox command initialization. */
-       if ((rc = lpfc_config_port_post(phba))) {
-               phba->hba_state = LPFC_HBA_ERROR;
-               mempool_free( pmb, phba->mbox_mem_pool);
-               return -ENXIO;
-       }
-       mempool_free( pmb, phba->mbox_mem_pool);
-       return 0;
-}
-
-
+       rc = lpfc_sli_ring_map(phba, pmb);
 
+       if (rc)
+               goto lpfc_sli_hba_setup_error;
 
+       phba->sli.sli_flag |= LPFC_PROCESS_LA;
 
+       rc = lpfc_config_port_post(phba);
+       if (rc)
+               goto lpfc_sli_hba_setup_error;
 
+       goto lpfc_sli_hba_setup_exit;
+lpfc_sli_hba_setup_error:
+       phba->hba_state = LPFC_HBA_ERROR;
+lpfc_sli_hba_setup_exit:
+       mempool_free(pmb, phba->mbox_mem_pool);
+       return rc;
+}
 
 static void
 lpfc_mbox_abort(struct lpfc_hba * phba)
 {
-       struct lpfc_sli *psli;
        LPFC_MBOXQ_t *pmbox;
        MAILBOX_t *mb;
-       struct lpfc_dmabuf *mp;
 
-       psli = &phba->sli;
-
-       if (psli->mbox_active) {
-               del_timer_sync(&psli->mbox_tmo);
-               pmbox = psli->mbox_active;
+       if (phba->sli.mbox_active) {
+               del_timer_sync(&phba->sli.mbox_tmo);
+               phba->work_hba_events &= ~WORKER_MBOX_TMO;
+               pmbox = phba->sli.mbox_active;
                mb = &pmbox->mb;
-               psli->mbox_active = NULL;
+               phba->sli.mbox_active = NULL;
                if (pmbox->mbox_cmpl) {
                        mb->mbxStatus = MBX_NOT_FINISHED;
                        (pmbox->mbox_cmpl) (phba, pmbox);
-               } else {
-                       mp = (struct lpfc_dmabuf *) (pmbox->context1);
-                       if (mp) {
-                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                               kfree(mp);
-                       }
-                       mempool_free( pmbox, phba->mbox_mem_pool);
                }
-               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+               phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
        }
 
        /* Abort all the non active mailbox commands. */
+       spin_lock_irq(phba->host->host_lock);
        pmbox = lpfc_mbox_get(phba);
        while (pmbox) {
                mb = &pmbox->mb;
                if (pmbox->mbox_cmpl) {
                        mb->mbxStatus = MBX_NOT_FINISHED;
+                       spin_unlock_irq(phba->host->host_lock);
                        (pmbox->mbox_cmpl) (phba, pmbox);
-               } else {
-                       mp = (struct lpfc_dmabuf *) (pmbox->context1);
-                       if (mp) {
-                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                               kfree(mp);
-                       }
-                       mempool_free( pmbox, phba->mbox_mem_pool);
+                       spin_lock_irq(phba->host->host_lock);
                }
                pmbox = lpfc_mbox_get(phba);
        }
+       spin_unlock_irq(phba->host->host_lock);
        return;
 }
+
 /*! lpfc_mbox_timeout
  *
  * \pre
@@ -1846,17 +1714,31 @@ void
 lpfc_mbox_timeout(unsigned long ptr)
 {
        struct lpfc_hba *phba;
-       struct lpfc_sli *psli;
-       LPFC_MBOXQ_t *pmbox;
-       MAILBOX_t *mb;
-       struct lpfc_dmabuf *mp;
        unsigned long iflag;
 
        phba = (struct lpfc_hba *)ptr;
-       psli = &phba->sli;
        spin_lock_irqsave(phba->host->host_lock, iflag);
+       if (!(phba->work_hba_events & WORKER_MBOX_TMO)) {
+               phba->work_hba_events |= WORKER_MBOX_TMO;
+               if (phba->work_wait)
+                       wake_up(phba->work_wait);
+       }
+       spin_unlock_irqrestore(phba->host->host_lock, iflag);
+}
+
+void
+lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
+{
+       LPFC_MBOXQ_t *pmbox;
+       MAILBOX_t *mb;
+
+       spin_lock_irq(phba->host->host_lock);
+       if (!(phba->work_hba_events & WORKER_MBOX_TMO)) {
+               spin_unlock_irq(phba->host->host_lock);
+               return;
+       }
 
-       pmbox = psli->mbox_active;
+       pmbox = phba->sli.mbox_active;
        mb = &pmbox->mb;
 
        /* Mbox cmd <mbxCommand> timeout */
@@ -1867,31 +1749,25 @@ lpfc_mbox_timeout(unsigned long ptr)
                phba->brd_no,
                mb->mbxCommand,
                phba->hba_state,
-               psli->sliinit.sli_flag,
-               psli->mbox_active);
+               phba->sli.sli_flag,
+               phba->sli.mbox_active);
 
-       if (psli->mbox_active == pmbox) {
-               psli->mbox_active = NULL;
+       if (phba->sli.mbox_active == pmbox) {
+               phba->sli.mbox_active = NULL;
                if (pmbox->mbox_cmpl) {
                        mb->mbxStatus = MBX_NOT_FINISHED;
+                       spin_unlock_irq(phba->host->host_lock);
                        (pmbox->mbox_cmpl) (phba, pmbox);
-               } else {
-                       mp = (struct lpfc_dmabuf *) (pmbox->context1);
-                       if (mp) {
-                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                               kfree(mp);
-                       }
-                       mempool_free( pmbox, phba->mbox_mem_pool);
+                       spin_lock_irq(phba->host->host_lock);
                }
-               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+               phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
        }
 
+       spin_unlock_irq(phba->host->host_lock);
        lpfc_mbox_abort(phba);
-       spin_unlock_irqrestore(phba->host->host_lock, iflag);
        return;
 }
 
-
 int
 lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
 {
@@ -1903,17 +1779,17 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
        int i;
        unsigned long drvr_flag = 0;
        volatile uint32_t word0, ldata;
-       void *to_slim;
+       void __iomem *to_slim;
 
        psli = &phba->sli;
-       if (flag & MBX_POLL) {
-               spin_lock_irqsave(phba->host->host_lock, drvr_flag);
-       }
+
+       spin_lock_irqsave(phba->host->host_lock, drvr_flag);
+
 
        mb = &pmbox->mb;
        status = MBX_SUCCESS;
 
-       if (psli->sliinit.sli_flag & LPFC_SLI_MBOX_ACTIVE) {
+       if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) {
                /* Polling for a mbox command when another one is already active
                 * is not allowed in SLI. Also, the driver must have established
                 * SLI2 mode to queue and process multiple mbox commands.
@@ -1928,8 +1804,9 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                        return (MBX_NOT_FINISHED);
                }
 
-               if (!(psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE)) {
-
+               if (!(psli->sli_flag & LPFC_SLI2_ACTIVE)) {
+                       spin_unlock_irqrestore(phba->host->host_lock,
+                                              drvr_flag);
                        /* Mbox command <mbxCommand> cannot issue */
                        LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag)
                        return (MBX_NOT_FINISHED);
@@ -1941,7 +1818,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                if (flag & MBX_STOP_IOCB) {
                        flag &= ~MBX_STOP_IOCB;
                        /* Now flag each ring */
-                       for (i = 0; i < psli->sliinit.num_rings; i++) {
+                       for (i = 0; i < psli->num_rings; i++) {
                                /* If the ring is active, flag it */
                                if (psli->ring[i].cmdringaddr) {
                                        psli->ring[i].flag |=
@@ -1963,14 +1840,13 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                        phba->brd_no,
                        mb->mbxCommand,
                        phba->hba_state,
-                       psli->sliinit.sli_flag,
+                       psli->sli_flag,
                        flag);
 
-               psli->slistat.mboxBusy++;
-               if (flag == MBX_POLL) {
-                       spin_unlock_irqrestore(phba->host->host_lock,
-                                              drvr_flag);
-               }
+               psli->slistat.mbox_busy++;
+               spin_unlock_irqrestore(phba->host->host_lock,
+                                      drvr_flag);
+
                return (MBX_BUSY);
        }
 
@@ -1981,7 +1857,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                flag &= ~MBX_STOP_IOCB;
                if (flag == MBX_NOWAIT) {
                        /* Now flag each ring */
-                       for (i = 0; i < psli->sliinit.num_rings; i++) {
+                       for (i = 0; i < psli->num_rings; i++) {
                                /* If the ring is active, flag it */
                                if (psli->ring[i].cmdringaddr) {
                                        psli->ring[i].flag |=
@@ -1991,13 +1867,14 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                }
        }
 
-       psli->sliinit.sli_flag |= LPFC_SLI_MBOX_ACTIVE;
+       psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE;
 
        /* If we are not polling, we MUST be in SLI2 mode */
        if (flag != MBX_POLL) {
-               if (!(psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE)) {
-                       psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
-
+               if (!(psli->sli_flag & LPFC_SLI2_ACTIVE)) {
+                       psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+                       spin_unlock_irqrestore(phba->host->host_lock,
+                                              drvr_flag);
                        /* Mbox command <mbxCommand> cannot issue */
                        LOG_MBOX_CANNOT_ISSUE_DATA( phba, mb, psli, flag);
                        return (MBX_NOT_FINISHED);
@@ -2014,42 +1891,32 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                phba->brd_no,
                mb->mbxCommand,
                phba->hba_state,
-               psli->sliinit.sli_flag,
+               psli->sli_flag,
                flag);
 
-       psli->slistat.mboxCmd++;
-       evtctr = psli->slistat.mboxEvent;
+       psli->slistat.mbox_cmd++;
+       evtctr = psli->slistat.mbox_event;
 
        /* next set own bit for the adapter and copy over command word */
        mb->mbxOwner = OWN_CHIP;
 
-       if (psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE) {
+       if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
 
                /* First copy command data to host SLIM area */
                mbox = (MAILBOX_t *) psli->MBhostaddr;
-               lpfc_sli_pcimem_bcopy((uint32_t *) mb, (uint32_t *) mbox,
-                                     (sizeof (uint32_t) *
-                                      (MAILBOX_CMD_WSIZE)));
-
-               pci_dma_sync_single_for_device(phba->pcidev,
-                                              phba->slim2p_mapping,
-                                              sizeof (MAILBOX_t),
-                                              PCI_DMA_TODEVICE);
+               lpfc_sli_pcimem_bcopy(mb, mbox, MAILBOX_CMD_SIZE);
        } else {
                if (mb->mbxCommand == MBX_CONFIG_PORT) {
                        /* copy command data into host mbox for cmpl */
                        mbox = (MAILBOX_t *) psli->MBhostaddr;
-                       lpfc_sli_pcimem_bcopy((uint32_t *) mb,
-                                             (uint32_t *) mbox,
-                                             (sizeof (uint32_t) *
-                                              (MAILBOX_CMD_WSIZE)));
+                       lpfc_sli_pcimem_bcopy(mb, mbox, MAILBOX_CMD_SIZE);
                }
 
                /* First copy mbox command data to HBA SLIM, skip past first
                   word */
-               to_slim = (uint8_t *) phba->MBslimaddr + sizeof (uint32_t);
-               lpfc_memcpy_to_slim(to_slim, (void *)&mb->un.varWords[0],
-                           (MAILBOX_CMD_WSIZE - 1) * sizeof (uint32_t));
+               to_slim = phba->MBslimaddr + sizeof (uint32_t);
+               lpfc_memcpy_to_slim(to_slim, &mb->un.varWords[0],
+                           MAILBOX_CMD_SIZE - sizeof (uint32_t));
 
                /* Next copy over first word, with mbxOwner set */
                ldata = *((volatile uint32_t *)mb);
@@ -2059,7 +1926,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
 
                if (mb->mbxCommand == MBX_CONFIG_PORT) {
                        /* switch over to host mailbox */
-                       psli->sliinit.sli_flag |= LPFC_SLI2_ACTIVE;
+                       psli->sli_flag |= LPFC_SLI2_ACTIVE;
                }
        }
 
@@ -2077,7 +1944,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
        case MBX_POLL:
                i = 0;
                psli->mbox_active = NULL;
-               if (psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE) {
+               if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
                        /* First read mbox status word */
                        mbox = (MAILBOX_t *) psli->MBhostaddr;
                        word0 = *((volatile uint32_t *)mbox);
@@ -2094,7 +1961,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                while (((word0 & OWN_CHIP) == OWN_CHIP)
                       || !(ha_copy & HA_MBATT)) {
                        if (i++ >= 100) {
-                               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+                               psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
                                spin_unlock_irqrestore(phba->host->host_lock,
                                                       drvr_flag);
                                return (MBX_NOT_FINISHED);
@@ -2103,7 +1970,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                        /* Check if we took a mbox interrupt while we were
                           polling */
                        if (((word0 & OWN_CHIP) != OWN_CHIP)
-                           && (evtctr != psli->slistat.mboxEvent))
+                           && (evtctr != psli->slistat.mbox_event))
                                break;
 
                        spin_unlock_irqrestore(phba->host->host_lock,
@@ -2115,7 +1982,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
 
                        spin_lock_irqsave(phba->host->host_lock, drvr_flag);
 
-                       if (psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE) {
+                       if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
                                /* First copy command data */
                                mbox = (MAILBOX_t *) psli->MBhostaddr;
                                word0 = *((volatile uint32_t *)mbox);
@@ -2128,7 +1995,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                                        slimmb = (MAILBOX_t *) & slimword0;
                                        if (((slimword0 & OWN_CHIP) != OWN_CHIP)
                                            && slimmb->mbxStatus) {
-                                               psli->sliinit.sli_flag &=
+                                               psli->sli_flag &=
                                                    ~LPFC_SLI2_ACTIVE;
                                                word0 = slimword0;
                                        }
@@ -2141,31 +2008,31 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
                        ha_copy = readl(phba->HAregaddr);
                }
 
-               if (psli->sliinit.sli_flag & LPFC_SLI2_ACTIVE) {
+               if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
                        /* First copy command data */
                        mbox = (MAILBOX_t *) psli->MBhostaddr;
                        /* copy results back to user */
-                       lpfc_sli_pcimem_bcopy((uint32_t *) mbox,
-                                             (uint32_t *) mb,
-                                             (sizeof (uint32_t) *
-                                              MAILBOX_CMD_WSIZE));
+                       lpfc_sli_pcimem_bcopy(mbox, mb, MAILBOX_CMD_SIZE);
                } else {
                        /* First copy command data */
-                       lpfc_memcpy_from_slim((void *)mb,
-                                     phba->MBslimaddr,
-                                     sizeof (uint32_t) * (MAILBOX_CMD_WSIZE));
+                       lpfc_memcpy_from_slim(mb, phba->MBslimaddr,
+                                                       MAILBOX_CMD_SIZE);
+                       if ((mb->mbxCommand == MBX_DUMP_MEMORY) &&
+                               pmbox->context2) {
+                               lpfc_memcpy_from_slim((void *)pmbox->context2,
+                                     phba->MBslimaddr + DMP_RSP_OFFSET,
+                                                     mb->un.varDmp.word_cnt);
+                       }
                }
 
                writel(HA_MBATT, phba->HAregaddr);
                readl(phba->HAregaddr); /* flush */
 
-               psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+               psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
                status = mb->mbxStatus;
        }
 
-       if (flag == MBX_POLL) {
-               spin_unlock_irqrestore(phba->host->host_lock, drvr_flag);
-       }
+       spin_unlock_irqrestore(phba->host->host_lock, drvr_flag);
        return (status);
 }
 
@@ -2180,7 +2047,7 @@ lpfc_sli_ringtx_put(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
 }
 
 static struct lpfc_iocbq *
-lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 
+lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                   struct lpfc_iocbq ** piocb)
 {
        struct lpfc_iocbq * nextiocb;
@@ -2198,8 +2065,6 @@ int
 lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                    struct lpfc_iocbq *piocb, uint32_t flag)
 {
-       struct lpfc_sli *psli = &phba->sli;
-       int ringno = pring->ringno;
        struct lpfc_iocbq *nextiocb;
        IOCB_t *iocb;
 
@@ -2243,8 +2108,8 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
         * For FCP commands, we must be in a state where we can process link
         * attention events.
         */
-       } else if (unlikely(pring->ringno == psli->fcp_ring &&
-                  !(psli->sliinit.sli_flag & LPFC_PROCESS_LA)))
+       } else if (unlikely(pring->ringno == phba->sli.fcp_ring &&
+                  !(phba->sli.sli_flag & LPFC_PROCESS_LA)))
                goto iocb_busy;
 
        /*
@@ -2260,7 +2125,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
        while ((iocb = lpfc_sli_next_iocb_slot(phba, pring)) &&
               (nextiocb = lpfc_sli_next_iocb(phba, pring, &piocb)))
                lpfc_sli_submit_iocb(phba, pring, iocb, nextiocb);
-       
+
        if (iocb)
                lpfc_sli_update_ring(phba, pring);
        else
@@ -2272,7 +2137,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
        goto out_busy;
 
  iocb_busy:
-       psli->slistat.iocbCmdDelay[ringno]++;
+       pring->stats.iocb_cmd_delay++;
 
  out_busy:
 
@@ -2284,6 +2149,89 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
        return IOCB_BUSY;
 }
 
+int
+lpfc_sli_setup(struct lpfc_hba *phba)
+{
+       int i, totiocb = 0;
+       struct lpfc_sli *psli = &phba->sli;
+       struct lpfc_sli_ring *pring;
+
+       psli->num_rings = MAX_CONFIGURED_RINGS;
+       psli->sli_flag = 0;
+       psli->fcp_ring = LPFC_FCP_RING;
+       psli->next_ring = LPFC_FCP_NEXT_RING;
+       psli->ip_ring = LPFC_IP_RING;
+
+       for (i = 0; i < psli->num_rings; i++) {
+               pring = &psli->ring[i];
+               switch (i) {
+               case LPFC_FCP_RING:     /* ring 0 - FCP */
+                       /* numCiocb and numRiocb are used in config_port */
+                       pring->numCiocb = SLI2_IOCB_CMD_R0_ENTRIES;
+                       pring->numRiocb = SLI2_IOCB_RSP_R0_ENTRIES;
+                       pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES;
+                       pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES;
+                       pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES;
+                       pring->numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES;
+                       pring->iotag_ctr = 0;
+                       pring->iotag_max =
+                           (phba->cfg_hba_queue_depth * 2);
+                       pring->fast_iotag = pring->iotag_max;
+                       pring->num_mask = 0;
+                       break;
+               case LPFC_IP_RING:      /* ring 1 - IP */
+                       /* numCiocb and numRiocb are used in config_port */
+                       pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES;
+                       pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES;
+                       pring->num_mask = 0;
+                       break;
+               case LPFC_ELS_RING:     /* ring 2 - ELS / CT */
+                       /* numCiocb and numRiocb are used in config_port */
+                       pring->numCiocb = SLI2_IOCB_CMD_R2_ENTRIES;
+                       pring->numRiocb = SLI2_IOCB_RSP_R2_ENTRIES;
+                       pring->fast_iotag = 0;
+                       pring->iotag_ctr = 0;
+                       pring->iotag_max = 4096;
+                       pring->num_mask = 4;
+                       pring->prt[0].profile = 0;      /* Mask 0 */
+                       pring->prt[0].rctl = FC_ELS_REQ;
+                       pring->prt[0].type = FC_ELS_DATA;
+                       pring->prt[0].lpfc_sli_rcv_unsol_event =
+                           lpfc_els_unsol_event;
+                       pring->prt[1].profile = 0;      /* Mask 1 */
+                       pring->prt[1].rctl = FC_ELS_RSP;
+                       pring->prt[1].type = FC_ELS_DATA;
+                       pring->prt[1].lpfc_sli_rcv_unsol_event =
+                           lpfc_els_unsol_event;
+                       pring->prt[2].profile = 0;      /* Mask 2 */
+                       /* NameServer Inquiry */
+                       pring->prt[2].rctl = FC_UNSOL_CTL;
+                       /* NameServer */
+                       pring->prt[2].type = FC_COMMON_TRANSPORT_ULP;
+                       pring->prt[2].lpfc_sli_rcv_unsol_event =
+                           lpfc_ct_unsol_event;
+                       pring->prt[3].profile = 0;      /* Mask 3 */
+                       /* NameServer response */
+                       pring->prt[3].rctl = FC_SOL_CTL;
+                       /* NameServer */
+                       pring->prt[3].type = FC_COMMON_TRANSPORT_ULP;
+                       pring->prt[3].lpfc_sli_rcv_unsol_event =
+                           lpfc_ct_unsol_event;
+                       break;
+               }
+               totiocb += (pring->numCiocb + pring->numRiocb);
+       }
+       if (totiocb > MAX_SLI2_IOCB) {
+               /* Too many cmd / rsp ring entries in SLI2 SLIM */
+               lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+                               "%d:0462 Too many cmd / rsp ring entries in "
+                               "SLI2 SLIM Data: x%x x%x\n",
+                               phba->brd_no, totiocb, MAX_SLI2_IOCB);
+       }
+
+       return 0;
+}
+
 int
 lpfc_sli_queue_setup(struct lpfc_hba * phba)
 {
@@ -2292,9 +2240,10 @@ lpfc_sli_queue_setup(struct lpfc_hba * phba)
        int i, cnt;
 
        psli = &phba->sli;
+       spin_lock_irq(phba->host->host_lock);
        INIT_LIST_HEAD(&psli->mboxq);
        /* Initialize list headers for txq and txcmplq as double linked lists */
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
+       for (i = 0; i < psli->num_rings; i++) {
                pring = &psli->ring[i];
                pring->ringno = i;
                pring->next_cmdidx  = 0;
@@ -2304,7 +2253,8 @@ lpfc_sli_queue_setup(struct lpfc_hba * phba)
                INIT_LIST_HEAD(&pring->txcmplq);
                INIT_LIST_HEAD(&pring->iocb_continueq);
                INIT_LIST_HEAD(&pring->postbufq);
-               cnt = psli->sliinit.ringinit[i].fast_iotag;
+               cnt = pring->fast_iotag;
+               spin_unlock_irq(phba->host->host_lock);
                if (cnt) {
                        pring->fast_lookup =
                                kmalloc(cnt * sizeof (struct lpfc_iocbq *),
@@ -2315,7 +2265,9 @@ lpfc_sli_queue_setup(struct lpfc_hba * phba)
                        memset((char *)pring->fast_lookup, 0,
                               cnt * sizeof (struct lpfc_iocbq *));
                }
+               spin_lock_irq(phba->host->host_lock);
        }
+       spin_unlock_irq(phba->host->host_lock);
        return (1);
 }
 
@@ -2325,21 +2277,23 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
        struct lpfc_sli *psli;
        struct lpfc_sli_ring *pring;
        LPFC_MBOXQ_t *pmb;
-       struct lpfc_dmabuf *mp;
        struct lpfc_iocbq *iocb, *next_iocb;
        IOCB_t *icmd = NULL;
        int i;
+       unsigned long flags = 0;
 
        psli = &phba->sli;
        lpfc_hba_down_prep(phba);
 
-       for (i = 0; i < psli->sliinit.num_rings; i++) {
+       spin_lock_irqsave(phba->host->host_lock, flags);
+
+       for (i = 0; i < psli->num_rings; i++) {
                pring = &psli->ring[i];
                pring->flag |= LPFC_DEFERRED_RING_EVENT;
 
                /*
                 * Error everything on the txq since these iocbs have not been
-                * given to the FW yet. 
+                * given to the FW yet.
                 */
                pring->txq_cnt = 0;
 
@@ -2349,9 +2303,13 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
                                icmd = &iocb->iocb;
                                icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
                                icmd->un.ulpWord[4] = IOERR_SLI_DOWN;
+                               spin_unlock_irqrestore(phba->host->host_lock,
+                                                      flags);
                                (iocb->iocb_cmpl) (phba, iocb, iocb);
+                               spin_lock_irqsave(phba->host->host_lock, flags);
                        } else {
-                               mempool_free( iocb, phba->iocb_mem_pool);
+                               list_add_tail(&iocb->list,
+                                             &phba->lpfc_iocb_list);
                        }
                }
 
@@ -2364,54 +2322,64 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
 
        }
 
+       spin_unlock_irqrestore(phba->host->host_lock, flags);
+
        /* Return any active mbox cmds */
        del_timer_sync(&psli->mbox_tmo);
-       if ((psli->mbox_active)) {
-                       pmb = psli->mbox_active;
-                       mp = (struct lpfc_dmabuf *) (pmb->context1);
-                       if (mp) {
-                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                               kfree(mp);
-                       }
-               mempool_free(psli->mbox_active, phba->mbox_mem_pool);
+       spin_lock_irqsave(phba->host->host_lock, flags);
+       phba->work_hba_events &= ~WORKER_MBOX_TMO;
+       if (psli->mbox_active) {
+               pmb = psli->mbox_active;
+               pmb->mb.mbxStatus = MBX_NOT_FINISHED;
+               if (pmb->mbox_cmpl) {
+                       spin_unlock_irqrestore(phba->host->host_lock, flags);
+                       pmb->mbox_cmpl(phba,pmb);
+                       spin_lock_irqsave(phba->host->host_lock, flags);
+               }
        }
-       psli->sliinit.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+       psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
        psli->mbox_active = NULL;
 
        /* Return any pending mbox cmds */
        while ((pmb = lpfc_mbox_get(phba)) != NULL) {
-               mp = (struct lpfc_dmabuf *) (pmb->context1);
-               if (mp) {
-                       lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                       kfree(mp);
+               pmb->mb.mbxStatus = MBX_NOT_FINISHED;
+               if (pmb->mbox_cmpl) {
+                       spin_unlock_irqrestore(phba->host->host_lock, flags);
+                       pmb->mbox_cmpl(phba,pmb);
+                       spin_lock_irqsave(phba->host->host_lock, flags);
                }
-               mempool_free(pmb, phba->mbox_mem_pool);
        }
 
        INIT_LIST_HEAD(&psli->mboxq);
 
+       spin_unlock_irqrestore(phba->host->host_lock, flags);
+
        /*
         * Provided the hba is not in an error state, reset it.  It is not
         * capable of IO anymore.
         */
        if (phba->hba_state != LPFC_HBA_ERROR) {
                phba->hba_state = LPFC_INIT_START;
-               lpfc_sli_brdreset(phba);
+               lpfc_sli_brdreset(phba, 1);
        }
 
        return 1;
 }
 
 void
-lpfc_sli_pcimem_bcopy(uint32_t * src, uint32_t * dest, uint32_t cnt)
+lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt)
 {
+       uint32_t *src = srcp;
+       uint32_t *dest = destp;
        uint32_t ldata;
        int i;
 
        for (i = 0; i < (int)cnt; i += sizeof (uint32_t)) {
-               ldata = *src++;
+               ldata = *src;
                ldata = le32_to_cpu(ldata);
-               *dest++ = ldata;
+               *dest = ldata;
+               src++;
+               dest++;
        }
 }
 
@@ -2440,8 +2408,6 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                if (mp->phys == phys) {
                        list_del_init(&mp->list);
                        pring->postbufq_cnt--;
-                       pci_dma_sync_single_for_cpu(phba->pcidev, mp->phys,
-                                       LPFC_BPL_SIZE, PCI_DMA_FROMDEVICE);
                        return mp;
                }
        }
@@ -2454,48 +2420,6 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
        return NULL;
 }
 
-uint32_t
-lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
-{
-       LPFC_RING_INIT_t *pringinit;
-       struct lpfc_sli *psli;
-       uint32_t search_start;
-
-       psli = &phba->sli;
-       pringinit = &psli->sliinit.ringinit[pring->ringno];
-
-       if (pring->fast_lookup == NULL) {
-               pringinit->iotag_ctr++;
-               if (pringinit->iotag_ctr >= pringinit->iotag_max)
-                       pringinit->iotag_ctr = 1;
-               return pringinit->iotag_ctr;
-       }
-
-       search_start = pringinit->iotag_ctr;
-
-       do {
-               pringinit->iotag_ctr++;
-               if (pringinit->iotag_ctr >= pringinit->fast_iotag)
-                       pringinit->iotag_ctr = 1;
-
-               if(*(pring->fast_lookup + pringinit->iotag_ctr) == NULL)
-                       return pringinit->iotag_ctr;
-
-       } while (pringinit->iotag_ctr != search_start);
-
-       /*
-        * Outstanding I/O count for ring <ringno> is at max <fast_iotag>
-        */
-       lpfc_printf_log(phba,
-               KERN_ERR,
-               LOG_SLI,
-               "%d:0318 Outstanding I/O count for ring %d is at max x%x\n",
-               phba->brd_no,
-               pring->ringno,
-               psli->sliinit.ringinit[pring->ringno].fast_iotag);
-       return (0);
-}
-
 static void
 lpfc_sli_abort_elsreq_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
                           struct lpfc_iocbq * rspiocb)
@@ -2510,12 +2434,10 @@ lpfc_sli_abort_elsreq_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
 
                /* Free the response IOCB before completing the abort
                   command.  */
-               if (!list_empty(&buf_ptr1->list)) {
-
-                       buf_ptr = list_entry(buf_ptr1->list.next,
-                                            struct lpfc_dmabuf, list);
-
-                       list_del(&buf_ptr->list);
+               buf_ptr = NULL;
+               list_remove_head((&buf_ptr1->list), buf_ptr,
+                                struct lpfc_dmabuf, list);
+               if (buf_ptr) {
                        lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
                        kfree(buf_ptr);
                }
@@ -2528,7 +2450,8 @@ lpfc_sli_abort_elsreq_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
                lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
                kfree(buf_ptr);
        }
-       mempool_free( cmdiocb, phba->iocb_mem_pool);
+
+       list_add_tail(&cmdiocb->list, &phba->lpfc_iocb_list);
        return;
 }
 
@@ -2537,25 +2460,21 @@ lpfc_sli_issue_abort_iotag32(struct lpfc_hba * phba,
                             struct lpfc_sli_ring * pring,
                             struct lpfc_iocbq * cmdiocb)
 {
-       struct lpfc_sli *psli;
-       struct lpfc_iocbq *abtsiocbp;
+       struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;
+       struct lpfc_iocbq *abtsiocbp = NULL;
        IOCB_t *icmd = NULL;
        IOCB_t *iabt = NULL;
-       uint32_t iotag32;
-
-       psli = &phba->sli;
 
        /* issue ABTS for this IOCB based on iotag */
-       if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool, GFP_ATOMIC)) == 0) {
-               return (0);
-       }
+       list_remove_head(lpfc_iocb_list, abtsiocbp, struct lpfc_iocbq, list);
+       if (abtsiocbp == NULL)
+               return 0;
        memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-       iabt = &abtsiocbp->iocb;
 
+       iabt = &abtsiocbp->iocb;
        icmd = &cmdiocb->iocb;
        switch (icmd->ulpCommand) {
        case CMD_ELS_REQUEST64_CR:
-               iotag32 = icmd->un.elsreq64.bdl.ulpIoTag32;
                /* Even though we abort the ELS command, the firmware may access
                 * the BPL or other resources before it processes our
                 * ABORT_MXRI64. Thus we must delay reusing the cmdiocb
@@ -2569,133 +2488,68 @@ lpfc_sli_issue_abort_iotag32(struct lpfc_hba * phba,
                abtsiocbp->iocb_cmpl = lpfc_sli_abort_elsreq_cmpl;
                break;
        default:
-               mempool_free( abtsiocbp, phba->iocb_mem_pool);
-               return (0);
+               list_add_tail(&abtsiocbp->list, lpfc_iocb_list);
+               return 0;
        }
 
        iabt->un.amxri.abortType = ABORT_TYPE_ABTS;
-       iabt->un.amxri.iotag32 = iotag32;
+       iabt->un.amxri.iotag32 = icmd->un.elsreq64.bdl.ulpIoTag32;
 
        iabt->ulpLe = 1;
        iabt->ulpClass = CLASS3;
        iabt->ulpCommand = CMD_ABORT_MXRI64_CN;
 
        if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) == IOCB_ERROR) {
-               mempool_free( abtsiocbp, phba->iocb_mem_pool);
-               return (0);
+               list_add_tail(&abtsiocbp->list, lpfc_iocb_list);
+               return 0;
        }
 
-       return (1);
+       return 1;
 }
 
-int
-lpfc_sli_abort_iocb_ctx(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
-                       uint32_t ctx)
+static int
+lpfc_sli_validate_iocb_cmd(struct lpfc_scsi_buf *lpfc_cmd, uint16_t tgt_id,
+                            uint64_t lun_id, struct lpfc_iocbq *iocb,
+                            uint32_t ctx, lpfc_ctx_cmd ctx_cmd)
 {
-       struct lpfc_sli *psli;
-       struct lpfc_iocbq *iocb, *next_iocb;
-       struct lpfc_iocbq *abtsiocbp;
-       IOCB_t *icmd = NULL, *cmd = NULL;
-       int errcnt;
+       int rc = 1;
 
-       psli = &phba->sli;
-       errcnt = 0;
+       if (lpfc_cmd == NULL)
+               return rc;
 
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-               cmd = &iocb->iocb;
-               if (cmd->ulpContext != ctx) {
-                       continue;
-               }
-
-               list_del_init(&iocb->list);
-               pring->txq_cnt--;
-               if (iocb->iocb_cmpl) {
-                       icmd = &iocb->iocb;
-                       icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
-                       icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
-                       (iocb->iocb_cmpl) (phba, iocb, iocb);
-               } else {
-                       mempool_free( iocb, phba->iocb_mem_pool);
-               }
+       switch (ctx_cmd) {
+       case LPFC_CTX_LUN:
+               if ((lpfc_cmd->pCmd->device->id == tgt_id) &&
+                   (lpfc_cmd->pCmd->device->lun == lun_id))
+                       rc = 0;
+               break;
+       case LPFC_CTX_TGT:
+               if (lpfc_cmd->pCmd->device->id == tgt_id)
+                       rc = 0;
+               break;
+       case LPFC_CTX_CTX:
+               if (iocb->iocb.ulpContext == ctx)
+                       rc = 0;
+       case LPFC_CTX_HOST:
+               rc = 0;
+               break;
+       default:
+               printk(KERN_ERR "%s: Unknown context cmd type, value %d\n",
+                       __FUNCTION__, ctx_cmd);
+               break;
        }
 
-       /* Next check the txcmplq */
-       list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
-               cmd = &iocb->iocb;
-               if (cmd->ulpContext != ctx) {
-                       continue;
-               }
-
-               /* issue ABTS for this IOCB based on iotag */
-               if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool,
-                                              GFP_ATOMIC)) == 0) {
-                       errcnt++;
-                       continue;
-               }
-               memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-               icmd = &abtsiocbp->iocb;
-
-               icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
-               icmd->un.acxri.abortContextTag = cmd->ulpContext;
-               icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
-
-               icmd->ulpLe = 1;
-               icmd->ulpClass = cmd->ulpClass;
-               if (phba->hba_state >= LPFC_LINK_UP) {
-                       icmd->ulpCommand = CMD_ABORT_XRI_CN;
-               } else {
-                       icmd->ulpCommand = CMD_CLOSE_XRI_CN;
-               }
-
-               if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) ==
-                                                               IOCB_ERROR) {
-                       mempool_free( abtsiocbp, phba->iocb_mem_pool);
-                       errcnt++;
-                       continue;
-               }
-               /* The rsp ring completion will remove IOCB from txcmplq when
-                * abort is read by HBA.
-                */
-       }
-       return (errcnt);
+       return rc;
 }
 
 int
-lpfc_sli_sum_iocb_host(struct lpfc_hba * phba,
-                       struct lpfc_sli_ring * pring)
+lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
+               uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd ctx_cmd)
 {
-       struct lpfc_sli *psli;
        struct lpfc_iocbq *iocb, *next_iocb;
        IOCB_t *cmd = NULL;
        struct lpfc_scsi_buf *lpfc_cmd;
-       int sum;
-
-       psli = &phba->sli;
-       sum = 0;
-
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-               cmd = &iocb->iocb;
-
-               /* Must be a FCP command */
-               if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                   (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                   (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                       continue;
-               }
-
-               /* context1 MUST be a struct lpfc_scsi_buf */
-               lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-               if (lpfc_cmd == 0) {
-                       continue;
-               }
-               sum++;
-       }
+       int sum = 0, ret_val = 0;
 
        /* Next check the txcmplq */
        list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
@@ -2710,153 +2564,27 @@ lpfc_sli_sum_iocb_host(struct lpfc_hba * phba,
 
                /* context1 MUST be a struct lpfc_scsi_buf */
                lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-               if (lpfc_cmd == 0) {
+               ret_val = lpfc_sli_validate_iocb_cmd(lpfc_cmd, tgt_id, lun_id,
+                                                    NULL, 0, ctx_cmd);
+               if (ret_val != 0)
                        continue;
-               }
                sum++;
        }
-       return (sum);
-}
-
-int
-lpfc_sli_abort_iocb_host(struct lpfc_hba * phba,
-                       struct lpfc_sli_ring * pring, int flag)
-{
-       struct lpfc_sli *psli;
-       struct lpfc_iocbq *iocb, *next_iocb;
-       struct lpfc_iocbq *abtsiocbp;
-       IOCB_t *icmd = NULL, *cmd = NULL;
-       struct lpfc_scsi_buf *lpfc_cmd;
-       int errcnt;
-
-       psli = &phba->sli;
-       errcnt = 0;
-
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       if(flag & LPFC_ABORT_TXQ) {
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
-
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if (lpfc_cmd == 0) {
-                               continue;
-                       }
-
-                       list_del_init(&iocb->list);
-                       pring->txq_cnt--;
-                       if (iocb->iocb_cmpl) {
-                               icmd = &iocb->iocb;
-                               icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
-                               icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
-                               (iocb->iocb_cmpl) (phba, iocb, iocb);
-                       } else {
-                               mempool_free( iocb, phba->iocb_mem_pool);
-                       }
-               }
-       }
-
-       if(flag & LPFC_ABORT_TXCMPLQ) {
-               /* Next check the txcmplq */
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq,
-                                        list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
-
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if (lpfc_cmd == 0) {
-                               continue;
-                       }
-
-                       /* issue ABTS for this IOCB based on iotag */
-                       if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool,
-                                                      GFP_ATOMIC)) == 0) {
-                               errcnt++;
-                               continue;
-                       }
-                       memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-                       icmd = &abtsiocbp->iocb;
-
-                       icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
-                       icmd->un.acxri.abortContextTag = cmd->ulpContext;
-                       icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
-
-                       icmd->ulpLe = 1;
-                       icmd->ulpClass = cmd->ulpClass;
-                       if (phba->hba_state >= LPFC_LINK_UP) {
-                               icmd->ulpCommand = CMD_ABORT_XRI_CN;
-                       } else {
-                               icmd->ulpCommand = CMD_CLOSE_XRI_CN;
-                       }
-
-                       if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) ==
-                                                               IOCB_ERROR) {
-                               mempool_free( abtsiocbp, phba->iocb_mem_pool);
-                               errcnt++;
-                               continue;
-                       }
-                       /* The rsp ring completion will remove IOCB from
-                        * tacmplq when abort is read by HBA.
-                        */
-               }
-       }
-       return (errcnt);
+       return sum;
 }
 
 int
-lpfc_sli_sum_iocb_lun(struct lpfc_hba * phba,
-                       struct lpfc_sli_ring * pring,
-                       uint16_t scsi_target, uint64_t scsi_lun)
+lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
+                   uint16_t tgt_id, uint64_t lun_id, uint32_t ctx,
+                   lpfc_ctx_cmd abort_cmd)
 {
-       struct lpfc_sli *psli;
        struct lpfc_iocbq *iocb, *next_iocb;
+       struct lpfc_iocbq *abtsiocb = NULL;
+       struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;
        IOCB_t *cmd = NULL;
        struct lpfc_scsi_buf *lpfc_cmd;
-       int sum;
+       int errcnt = 0, ret_val = 0;
 
-       psli = &phba->sli;
-       sum = 0;
-
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-               cmd = &iocb->iocb;
-
-               /* Must be a FCP command */
-               if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                   (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                   (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                       continue;
-               }
-
-               /* context1 MUST be a struct lpfc_scsi_buf */
-               lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-               if ((lpfc_cmd == 0) ||
-                   (lpfc_cmd->pCmd->device->id != scsi_target) ||
-                   (lpfc_cmd->pCmd->device->lun != scsi_lun)) {
-                       continue;
-               }
-               sum++;
-       }
-
-       /* Next check the txcmplq */
        list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
                cmd = &iocb->iocb;
 
@@ -2869,229 +2597,42 @@ lpfc_sli_sum_iocb_lun(struct lpfc_hba * phba,
 
                /* context1 MUST be a struct lpfc_scsi_buf */
                lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-               if ((lpfc_cmd == 0) ||
-                   (lpfc_cmd->pCmd->device->id != scsi_target) ||
-                   (lpfc_cmd->pCmd->device->lun != scsi_lun)) {
+               ret_val = lpfc_sli_validate_iocb_cmd(lpfc_cmd, tgt_id, lun_id,
+                                                    iocb, ctx, abort_cmd);
+               if (ret_val != 0)
                        continue;
-               }
-
-               sum++;
-       }
-       return (sum);
-}
-
-int
-lpfc_sli_abort_iocb_lun(struct lpfc_hba * phba,
-                       struct lpfc_sli_ring * pring,
-                       uint16_t scsi_target, uint64_t scsi_lun, int flag)
-{
-       struct lpfc_sli *psli;
-       struct lpfc_iocbq *iocb, *next_iocb;
-       struct lpfc_iocbq *abtsiocbp;
-       IOCB_t *icmd = NULL, *cmd = NULL;
-       struct lpfc_scsi_buf *lpfc_cmd;
-       int errcnt;
-
-       psli = &phba->sli;
-       errcnt = 0;
-
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       if(flag & LPFC_ABORT_TXQ) {
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
-
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if ((lpfc_cmd == 0) ||
-                           (lpfc_cmd->pCmd->device->id != scsi_target) ||
-                           (lpfc_cmd->pCmd->device->lun != scsi_lun)) {
-                               continue;
-                       }
-
-                       list_del_init(&iocb->list);
-                       pring->txq_cnt--;
-                       if (iocb->iocb_cmpl) {
-                               icmd = &iocb->iocb;
-                               icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
-                               icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
-                               (iocb->iocb_cmpl) (phba, iocb, iocb);
-                       } else {
-                               mempool_free( iocb, phba->iocb_mem_pool);
-                       }
-               }
-       }
-
-       if(flag & LPFC_ABORT_TXCMPLQ) {
-               /* Next check the txcmplq */
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq,
-                                        list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
-
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if ((lpfc_cmd == 0) ||
-                           (lpfc_cmd->pCmd->device->id != scsi_target) ||
-                           (lpfc_cmd->pCmd->device->lun != scsi_lun)) {
-                               continue;
-                       }
 
-                       /* issue ABTS for this IOCB based on iotag */
-                       if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool,
-                                                      GFP_ATOMIC)) == 0) {
-                               errcnt++;
-                               continue;
-                       }
-                       memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-                       icmd = &abtsiocbp->iocb;
-
-                       icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
-                       icmd->un.acxri.abortContextTag = cmd->ulpContext;
-                       icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
-
-                       icmd->ulpLe = 1;
-                       icmd->ulpClass = cmd->ulpClass;
-                       if (phba->hba_state >= LPFC_LINK_UP) {
-                               icmd->ulpCommand = CMD_ABORT_XRI_CN;
-                       } else {
-                               icmd->ulpCommand = CMD_CLOSE_XRI_CN;
-                       }
-
-                       if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) ==
-                                                               IOCB_ERROR) {
-                               mempool_free( abtsiocbp, phba->iocb_mem_pool);
-                               errcnt++;
-                               continue;
-                       }
-                       /* The rsp ring completion will remove IOCB from
-                        * tacmplq when abort is read by HBA.
-                        */
+               /* issue ABTS for this IOCB based on iotag */
+               list_remove_head(lpfc_iocb_list, abtsiocb, struct lpfc_iocbq,
+                                list);
+               if (abtsiocb == NULL) {
+                       errcnt++;
+                       continue;
                }
-       }
-       return (errcnt);
-}
+               memset(abtsiocb, 0, sizeof (struct lpfc_iocbq));
 
-int
-lpfc_sli_abort_iocb_tgt(struct lpfc_hba * phba,
-                       struct lpfc_sli_ring * pring,
-                       uint16_t scsi_target, int flag)
-{
-       struct lpfc_sli *psli;
-       struct lpfc_iocbq *iocb, *next_iocb;
-       struct lpfc_iocbq *abtsiocbp;
-       IOCB_t *icmd = NULL, *cmd = NULL;
-       struct lpfc_scsi_buf *lpfc_cmd;
-       int errcnt;
-
-       psli = &phba->sli;
-       errcnt = 0;
-
-       /* Error matching iocb on txq or txcmplq
-        * First check the txq.
-        */
-       if(flag & LPFC_ABORT_TXQ) {
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                       (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
+               abtsiocb->iocb.un.acxri.abortType = ABORT_TYPE_ABTS;
+               abtsiocb->iocb.un.acxri.abortContextTag = cmd->ulpContext;
+               abtsiocb->iocb.un.acxri.abortIoTag = cmd->ulpIoTag;
+               abtsiocb->iocb.ulpLe = 1;
+               abtsiocb->iocb.ulpClass = cmd->ulpClass;
 
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if ((lpfc_cmd == 0)
-                           || (lpfc_cmd->pCmd->device->id != scsi_target)) {
-                               continue;
-                       }
+               if (phba->hba_state >= LPFC_LINK_UP)
+                       abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN;
+               else
+                       abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN;
 
-                       list_del_init(&iocb->list);
-                       pring->txq_cnt--;
-                       if (iocb->iocb_cmpl) {
-                               icmd = &iocb->iocb;
-                               icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
-                               icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
-                               (iocb->iocb_cmpl) (phba, iocb, iocb);
-                       } else {
-                               mempool_free( iocb, phba->iocb_mem_pool);
-                       }
+               ret_val = lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0);
+               if (ret_val == IOCB_ERROR) {
+                       list_add_tail(&abtsiocb->list, lpfc_iocb_list);
+                       errcnt++;
+                       continue;
                }
        }
 
-       if(flag & LPFC_ABORT_TXCMPLQ) {
-               /* Next check the txcmplq */
-               list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq,
-                                        list) {
-                       cmd = &iocb->iocb;
-
-                       /* Must be a FCP command */
-                       if ((cmd->ulpCommand != CMD_FCP_ICMND64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IWRITE64_CR) &&
-                           (cmd->ulpCommand != CMD_FCP_IREAD64_CR)) {
-                               continue;
-                       }
-
-                       /* context1 MUST be a struct lpfc_scsi_buf */
-                       lpfc_cmd = (struct lpfc_scsi_buf *) (iocb->context1);
-                       if ((lpfc_cmd == 0)
-                           || (lpfc_cmd->pCmd->device->id != scsi_target)) {
-                               continue;
-                       }
-
-                       /* issue ABTS for this IOCB based on iotag */
-                       if ((abtsiocbp = mempool_alloc(phba->iocb_mem_pool,
-                               GFP_ATOMIC)) == 0) {
-                               errcnt++;
-                               continue;
-                       }
-                       memset(abtsiocbp, 0, sizeof (struct lpfc_iocbq));
-                       icmd = &abtsiocbp->iocb;
-
-                       icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
-                       icmd->un.acxri.abortContextTag = cmd->ulpContext;
-                       icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
-
-                       icmd->ulpLe = 1;
-                       icmd->ulpClass = cmd->ulpClass;
-                       if (phba->hba_state >= LPFC_LINK_UP) {
-                               icmd->ulpCommand = CMD_ABORT_XRI_CN;
-                       } else {
-                               icmd->ulpCommand = CMD_CLOSE_XRI_CN;
-                       }
-
-                       if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) ==
-                                                               IOCB_ERROR) {
-                               mempool_free( abtsiocbp, phba->iocb_mem_pool);
-                               errcnt++;
-                               continue;
-                       }
-                       /* The rsp ring completion will remove IOCB from
-                        * txcmplq when abort is read by HBA.
-                        */
-               }
-       }
-       return (errcnt);
+       return errcnt;
 }
 
-
-
 void
 lpfc_sli_wake_iocb_high_priority(struct lpfc_hba * phba,
                                 struct lpfc_iocbq * queue1,
@@ -3157,11 +2698,7 @@ lpfc_sli_issue_iocb_wait_high_priority(struct lpfc_hba * phba,
        retval = IOCB_ERROR;
        spin_unlock_irq(phba->host->host_lock);
        for (j = 0; j < 64; j++) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)
-               mdelay(delay_time);
-#else
                msleep(delay_time);
-#endif
                if (piocb->iocb_flag & LPFC_IO_HIPRI) {
                        piocb->iocb_flag &= ~LPFC_IO_HIPRI;
                        retval = IOCB_SUCCESS;
@@ -3173,21 +2710,6 @@ lpfc_sli_issue_iocb_wait_high_priority(struct lpfc_hba * phba,
        piocb->context2 = NULL;
        return retval;
 }
-static void
-lpfc_sli_wake_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
-{
-       wait_queue_head_t *pdone_q;
-
-       /*
-        * If pdone_q is empty, the driver thread gave up waiting and
-        * continued running.
-        */
-       pdone_q = (wait_queue_head_t *) pmboxq->context1;
-       if (pdone_q)
-               wake_up_interruptible(pdone_q);
-       return;
-}
-
 int
 lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
                         uint32_t timeout)
@@ -3212,9 +2734,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
        add_wait_queue(&done_q, &wq_entry);
 
        /* now issue the command */
-       spin_lock_irq(phba->host->host_lock);
        retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
-       spin_unlock_irq(phba->host->host_lock);
 
        if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
                timeleft = schedule_timeout(timeout * HZ);
@@ -3234,116 +2754,132 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
        return retval;
 }
 
-static void
-lpfc_sli_wake_iocb_wait(struct lpfc_hba * phba,
-                       struct lpfc_iocbq * queue1, struct lpfc_iocbq * queue2)
+irqreturn_t
+lpfc_intr_handler(int irq, void *dev_id, struct pt_regs * regs)
 {
-       wait_queue_head_t *pdone_q;
-
-       queue1->iocb_flag |= LPFC_IO_WAIT;
-       if (queue1->context2 && queue2)
-               memcpy(queue1->context2, queue2, sizeof (struct lpfc_iocbq));
+       struct lpfc_hba *phba;
+       uint32_t ha_copy;
+       uint32_t work_ha_copy;
+       unsigned long status;
+       int i;
+       uint32_t control;
 
        /*
-        * If pdone_q is empty, the waiter gave up and returned and this
-        * call has nothing to do.
+        * Get the driver's phba structure from the dev_id and
+        * assume the HBA is not interrupting.
         */
-       pdone_q = queue1->context_un.hipri_wait_queue;
-       if (pdone_q) {
-               wake_up(pdone_q);
-       }
-
-       return;
-}
+       phba = (struct lpfc_hba *) dev_id;
 
-int
-lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
-                        struct lpfc_sli_ring * pring,
-                        struct lpfc_iocbq * piocb,
-                        struct lpfc_iocbq * prspiocbq, uint32_t timeout)
-{
-       DECLARE_WAIT_QUEUE_HEAD(done_q);
-       DECLARE_WAITQUEUE(wq_entry, current);
-       uint32_t timeleft = 0;
-       int retval;
+       if (unlikely(!phba))
+               return IRQ_NONE;
 
-       /* The caller must leave context1 empty for the driver. */
-       if (piocb->context_un.hipri_wait_queue != 0)
-               return (IOCB_ERROR);
+       phba->sli.slistat.sli_intr++;
 
-       /* If the caller has provided a response iocbq buffer, then context2
-        * is NULL or its an error.
+       /*
+        * Call the HBA to see if it is interrupting.  If not, don't claim
+        * the interrupt
         */
-       if (prspiocbq) {
-               if (piocb->context2)
-                       return (IOCB_ERROR);
-               piocb->context2 = prspiocbq;
-       }
 
-       /* setup wake call as IOCB callback */
-       piocb->iocb_cmpl = lpfc_sli_wake_iocb_wait;
-       /* setup context field to pass wait_queue pointer to wake function  */
-       piocb->context_un.hipri_wait_queue = &done_q;
+       /* Ignore all interrupts during initialization. */
+       if (unlikely(phba->hba_state < LPFC_LINK_DOWN))
+               return IRQ_NONE;
 
-       /* start to sleep before we wait, to avoid races */
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       add_wait_queue(&done_q, &wq_entry);
+       /*
+        * Read host attention register to determine interrupt source
+        * Clear Attention Sources, except Error Attention (to
+        * preserve status) and Link Attention
+        */
+       spin_lock(phba->host->host_lock);
+       ha_copy = readl(phba->HAregaddr);
+       writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr);
+       readl(phba->HAregaddr); /* flush */
+       spin_unlock(phba->host->host_lock);
 
-       /* now issue the command */
-       retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0);
-       if (retval == IOCB_SUCCESS) {
-               /* Give up thread time and wait for the iocb to complete or for
-                * the alloted time to expire.
-                */
-               timeleft = schedule_timeout(timeout * HZ);
+       if (unlikely(!ha_copy))
+               return IRQ_NONE;
 
-               piocb->context_un.hipri_wait_queue = NULL;
-               piocb->iocb_cmpl = NULL;
-               if (piocb->context2 == prspiocbq)
-                       piocb->context2 = NULL;
+       work_ha_copy = ha_copy & phba->work_ha_mask;
 
-               /*
-                * Catch the error cases.  A timeleft of zero is an error since
-                * the iocb should have completed.  The iocb_flag not have value
-                * LPFC_IO_WAIT is also an error since the wakeup callback sets
-                * this flag when it runs.  Handle each.
-                */
-               if (timeleft == 0) {
-                       printk(KERN_WARNING "lpfc driver detected iocb "
-                              "Timeout!\n");
-                       retval = IOCB_TIMEDOUT;
-               } else if (!(piocb->iocb_flag & LPFC_IO_WAIT)) {
-                       printk(KERN_WARNING "lpfc driver detected iocb "
-                              "flag = 0x%X\n", piocb->iocb_flag);
-                       retval = IOCB_TIMEDOUT;
+       if (unlikely(work_ha_copy)) {
+               if (work_ha_copy & HA_LATT) {
+                       if (phba->sli.sli_flag & LPFC_PROCESS_LA) {
+                               /*
+                                * Turn off Link Attention interrupts
+                                * until CLEAR_LA done
+                                */
+                               spin_lock(phba->host->host_lock);
+                               phba->sli.sli_flag &= ~LPFC_PROCESS_LA;
+                               control = readl(phba->HCregaddr);
+                               control &= ~HC_LAINT_ENA;
+                               writel(control, phba->HCregaddr);
+                               readl(phba->HCregaddr); /* flush */
+                               spin_unlock(phba->host->host_lock);
+                       }
+                       else
+                               work_ha_copy &= ~HA_LATT;
+               }
+
+               if (work_ha_copy & ~(HA_ERATT|HA_MBATT|HA_LATT)) {
+                       for (i = 0; i < phba->sli.num_rings; i++) {
+                               if (work_ha_copy & (HA_RXATT << (4*i))) {
+                                       /*
+                                        * Turn off Slow Rings interrupts
+                                        */
+                                       spin_lock(phba->host->host_lock);
+                                       control = readl(phba->HCregaddr);
+                                       control &= ~(HC_R0INT_ENA << i);
+                                       writel(control, phba->HCregaddr);
+                                       readl(phba->HCregaddr); /* flush */
+                                       spin_unlock(phba->host->host_lock);
+                               }
+                       }
                }
-       }
 
-       remove_wait_queue(&done_q, &wq_entry);
-       set_current_state(TASK_RUNNING);
-       piocb->context2 = NULL;
-       return retval;
-}
+               if (work_ha_copy & HA_ERATT) {
+                       phba->hba_state = LPFC_HBA_ERROR;
+                       /*
+                        * There was a link/board error.  Read the
+                        * status register to retrieve the error event
+                        * and process it.
+                        */
+                       phba->sli.slistat.err_attn_event++;
+                       /* Save status info */
+                       phba->work_hs = readl(phba->HSregaddr);
+                       phba->work_status[0] = readl(phba->MBslimaddr + 0xa8);
+                       phba->work_status[1] = readl(phba->MBslimaddr + 0xac);
 
-irqreturn_t
-lpfc_intr_handler(int irq, void *dev_id, struct pt_regs * regs)
-{
-       struct lpfc_hba *phba;
-       int intr_status;
+                       /* Clear Chip error bit */
+                       writel(HA_ERATT, phba->HAregaddr);
+                       readl(phba->HAregaddr); /* flush */
 
-       /*
-        * Get the driver's phba structure from the dev_id and
-        * assume the HBA is not interrupting.
-        */
-       phba = (struct lpfc_hba *) dev_id;
+                       /*
+                        * Reseting the HBA is the only reliable way
+                        * to shutdown interrupt when there is a
+                        * ERROR.
+                        */
+                       lpfc_sli_send_reset(phba, phba->hba_state);
+               }
 
-       if (phba) {
-               /* Call SLI to handle the interrupt event. */
-               intr_status = lpfc_sli_intr(phba);
-               if (intr_status == 0)
-                       return IRQ_HANDLED;
+               spin_lock(phba->host->host_lock);
+               phba->work_ha |= work_ha_copy;
+               if (phba->work_wait)
+                       wake_up(phba->work_wait);
+               spin_unlock(phba->host->host_lock);
        }
 
-       return IRQ_NONE;
+       ha_copy &= ~(phba->work_ha_mask);
+
+       /*
+        * Process all events on FCP ring.  Take the optimized path for
+        * FCP IO.  Any other IO is slow path and is handled by
+        * the worker thread.
+        */
+       status = (ha_copy & (HA_RXMASK  << (4*LPFC_FCP_RING)));
+       status >>= (4*LPFC_FCP_RING);
+       if (status & HA_RXATT)
+               lpfc_sli_handle_fast_ring_event(phba,
+                                               &phba->sli.ring[LPFC_FCP_RING],
+                                               status);
+       return IRQ_HANDLED;
 
 } /* lpfc_intr_handler */