#define IOERR_BUFFER_SHORTAGE         0x28
 #define IOERR_DEFAULT                 0x29
 #define IOERR_CNT                     0x2A
+#define IOERR_SLER_FAILURE            0x46
+#define IOERR_SLER_CMD_RCV_FAILURE    0x47
+#define IOERR_SLER_REC_RJT_ERR        0x48
+#define IOERR_SLER_REC_SRR_RETRY_ERR  0x49
+#define IOERR_SLER_SRR_RJT_ERR        0x4A
+#define IOERR_SLER_RRQ_RJT_ERR        0x4C
+#define IOERR_SLER_RRQ_RETRY_ERR      0x4D
+#define IOERR_SLER_ABTS_ERR           0x4E
 
 #define IOERR_DRVR_MASK               0x100
 #define IOERR_SLI_DOWN                0x101  /* ulpStatus  - Driver defined */
 
        mempool_free(pmb, phba->mbox_mem_pool);
 
        /* Reset the DFT_HBA_Q_DEPTH to the max xri  */
-       if (phba->cfg_hba_queue_depth > (phba->sli4_hba.max_cfg_param.max_xri))
+       if (phba->cfg_hba_queue_depth >
+               (phba->sli4_hba.max_cfg_param.max_xri -
+                       lpfc_sli4_get_els_iocb_cnt(phba)))
                phba->cfg_hba_queue_depth =
-                               phba->sli4_hba.max_cfg_param.max_xri;
+                       phba->sli4_hba.max_cfg_param.max_xri -
+                               lpfc_sli4_get_els_iocb_cnt(phba);
        return rc;
 }
 
 
                /* Allocate iotag for psb->cur_iocbq. */
                iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq);
                if (iotag == 0) {
+                       pci_pool_free(phba->lpfc_scsi_dma_buf_pool,
+                               psb->data, psb->dma_handle);
                        kfree(psb);
                        break;
                }
                case IOSTAT_LOCAL_REJECT:
                        if (lpfc_cmd->result == IOERR_INVALID_RPI ||
                            lpfc_cmd->result == IOERR_NO_RESOURCES ||
-                           lpfc_cmd->result == IOERR_ABORT_REQUESTED) {
+                           lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
+                           lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
                                cmd->result = ScsiResult(DID_REQUEUE, 0);
                                break;
                        }