Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
[pandora-kernel.git] / drivers / scsi / qla2xxx / qla_init.c
index 920b76b..def6942 100644 (file)
@@ -153,11 +153,10 @@ qla2x00_async_iocb_timeout(srb_t *sp)
        fc_port_t *fcport = sp->fcport;
        struct srb_ctx *ctx = sp->ctx;
 
-       DEBUG2(printk(KERN_WARNING
-               "scsi(%ld:%x): Async-%s timeout - portid=%02x%02x%02x.\n",
-               fcport->vha->host_no, sp->handle,
-               ctx->name, fcport->d_id.b.domain,
-               fcport->d_id.b.area, fcport->d_id.b.al_pa));
+       ql_dbg(ql_dbg_disc, fcport->vha, 0x2071,
+           "Async-%s timeout - portid=%02x%02x%02x.\n",
+           ctx->name, fcport->d_id.b.domain, fcport->d_id.b.area,
+           fcport->d_id.b.al_pa);
 
        fcport->flags &= ~FCF_ASYNC_SENT;
        if (ctx->type == SRB_LOGIN_CMD) {
@@ -211,11 +210,10 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
 
-       DEBUG2(printk(KERN_DEBUG
-           "scsi(%ld:%x): Async-login - loop-id=%x portid=%02x%02x%02x "
-           "retries=%d.\n", fcport->vha->host_no, sp->handle, fcport->loop_id,
-           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa,
-           fcport->login_retry));
+       ql_dbg(ql_dbg_disc, vha, 0x2072,
+           "Async-login - loopid=%x portid=%02x%02x%02x retries=%d.\n",
+           fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
+           fcport->d_id.b.al_pa, fcport->login_retry);
        return rval;
 
 done_free_sp:
@@ -259,10 +257,10 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
 
-       DEBUG2(printk(KERN_DEBUG
-           "scsi(%ld:%x): Async-logout - loop-id=%x portid=%02x%02x%02x.\n",
-           fcport->vha->host_no, sp->handle, fcport->loop_id,
-           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa));
+       ql_dbg(ql_dbg_disc, vha, 0x2070,
+           "Async-logout - loop-id=%x portid=%02x%02x%02x.\n",
+           fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
+           fcport->d_id.b.al_pa);
        return rval;
 
 done_free_sp:
@@ -309,11 +307,10 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
 
-       DEBUG2(printk(KERN_DEBUG
-           "scsi(%ld:%x): Async-adisc - loop-id=%x portid=%02x%02x%02x.\n",
-           fcport->vha->host_no, sp->handle, fcport->loop_id,
-           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa));
-
+       ql_dbg(ql_dbg_disc, vha, 0x206f,
+           "Async-adisc - loopid=%x portid=%02x%02x%02x.\n",
+           fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
+           fcport->d_id.b.al_pa);
        return rval;
 
 done_free_sp:
@@ -362,11 +359,10 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
 
-       DEBUG2(printk(KERN_DEBUG
-           "scsi(%ld:%x): Async-tmf - loop-id=%x portid=%02x%02x%02x.\n",
-           fcport->vha->host_no, sp->handle, fcport->loop_id,
-           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa));
-
+       ql_dbg(ql_dbg_taskm, vha, 0x802f,
+           "Async-tmf loop-id=%x portid=%02x%02x%02x.\n",
+           fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
+           fcport->d_id.b.al_pa);
        return rval;
 
 done_free_sp:
@@ -471,9 +467,8 @@ qla2x00_async_tm_cmd_done(struct scsi_qla_host *vha, fc_port_t *fcport,
                flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
 
        if ((rval != QLA_SUCCESS) || iocb->u.tmf.data) {
-               DEBUG2_3_11(printk(KERN_WARNING
-                       "%s(%ld): TM IOCB failed (%x).\n",
-                       __func__, vha->host_no, rval));
+               ql_dbg(ql_dbg_taskm, vha, 0x8030,
+                   "TM IOCB failed (%x).\n", rval);
        }
 
        return;
@@ -519,11 +514,12 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
        set_bit(0, ha->req_qid_map);
        set_bit(0, ha->rsp_qid_map);
 
-       qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
+       ql_log(ql_log_info, vha, 0x0040,
+           "Configuring PCI space...\n");
        rval = ha->isp_ops->pci_config(vha);
        if (rval) {
-               DEBUG2(printk("scsi(%ld): Unable to configure PCI space.\n",
-                   vha->host_no));
+               ql_log(ql_log_warn, vha, 0x0044,
+                   "Unable to configure PCI space.\n");
                return (rval);
        }
 
@@ -531,20 +527,21 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
 
        rval = qla2xxx_get_flash_info(vha);
        if (rval) {
-               DEBUG2(printk("scsi(%ld): Unable to validate FLASH data.\n",
-                   vha->host_no));
+               ql_log(ql_log_fatal, vha, 0x004f,
+                   "Unable to validate FLASH data.\n");
                return (rval);
        }
 
        ha->isp_ops->get_flash_version(vha, req->ring);
-
-       qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
+       ql_log(ql_log_info, vha, 0x0061,
+           "Configure NVRAM parameters...\n");
 
        ha->isp_ops->nvram_config(vha);
 
        if (ha->flags.disable_serdes) {
                /* Mask HBA via NVRAM settings? */
-               qla_printk(KERN_INFO, ha, "Masking HBA WWPN "
+               ql_log(ql_log_info, vha, 0x0077,
+                   "Masking HBA WWPN "
                    "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n",
                    vha->port_name[0], vha->port_name[1],
                    vha->port_name[2], vha->port_name[3],
@@ -553,7 +550,8 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
                return QLA_FUNCTION_FAILED;
        }
 
-       qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
+       ql_log(ql_log_info, vha, 0x0078,
+           "Verifying loaded RISC code...\n");
 
        if (qla2x00_isp_firmware(vha) != QLA_SUCCESS) {
                rval = ha->isp_ops->chip_diag(vha);
@@ -567,7 +565,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
        if (IS_QLA84XX(ha)) {
                ha->cs84xx = qla84xx_get_chip(vha);
                if (!ha->cs84xx) {
-                       qla_printk(KERN_ERR, ha,
+                       ql_log(ql_log_warn, vha, 0x00d0,
                            "Unable to configure ISP84XX.\n");
                        return QLA_FUNCTION_FAILED;
                }
@@ -579,8 +577,8 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
                /* Issue verify 84xx FW IOCB to complete 84xx initialization */
                rval = qla84xx_init_chip(vha);
                if (rval != QLA_SUCCESS) {
-                       qla_printk(KERN_ERR, ha,
-                               "Unable to initialize ISP84XX.\n");
+                       ql_log(ql_log_warn, vha, 0x00d4,
+                           "Unable to initialize ISP84XX.\n");
                qla84xx_put_chip(vha);
                }
        }
@@ -797,9 +795,7 @@ qla2x00_isp_firmware(scsi_qla_host_t *vha)
        rval = QLA_FUNCTION_FAILED;
 
        if (ha->flags.disable_risc_code_load) {
-               DEBUG2(printk("scsi(%ld): RISC CODE NOT loaded\n",
-                   vha->host_no));
-               qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n");
+               ql_log(ql_log_info, vha, 0x0079, "RISC CODE NOT loaded.\n");
 
                /* Verify checksum of loaded RISC code. */
                rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address);
@@ -810,10 +806,9 @@ qla2x00_isp_firmware(scsi_qla_host_t *vha)
                }
        }
 
-       if (rval) {
-               DEBUG2_3(printk("scsi(%ld): **** Load RISC code ****\n",
-                   vha->host_no));
-       }
+       if (rval)
+               ql_dbg(ql_dbg_init, vha, 0x007a,
+                   "**** Load RISC code ****.\n");
 
        return (rval);
 }
@@ -1105,8 +1100,8 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
        /* Assume a failed state */
        rval = QLA_FUNCTION_FAILED;
 
-       DEBUG3(printk("scsi(%ld): Testing device at %lx.\n",
-           vha->host_no, (u_long)&reg->flash_address));
+       ql_dbg(ql_dbg_init, vha, 0x007b,
+           "Testing device at %lx.\n", (u_long)&reg->flash_address);
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
 
@@ -1128,8 +1123,8 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
        if (!cnt)
                goto chip_diag_failed;
 
-       DEBUG3(printk("scsi(%ld): Reset register cleared by chip reset\n",
-           vha->host_no));
+       ql_dbg(ql_dbg_init, vha, 0x007c,
+           "Reset register cleared by chip reset.\n");
 
        /* Reset RISC processor. */
        WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
@@ -1150,7 +1145,7 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
                goto chip_diag_failed;
 
        /* Check product ID of chip */
-       DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", vha->host_no));
+       ql_dbg(ql_dbg_init, vha, 0x007d, "Checking product Id of chip.\n");
 
        mb[1] = RD_MAILBOX_REG(ha, reg, 1);
        mb[2] = RD_MAILBOX_REG(ha, reg, 2);
@@ -1158,8 +1153,9 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
        mb[4] = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 4));
        if (mb[1] != PROD_ID_1 || (mb[2] != PROD_ID_2 && mb[2] != PROD_ID_2a) ||
            mb[3] != PROD_ID_3) {
-               qla_printk(KERN_WARNING, ha,
-                   "Wrong product ID = 0x%x,0x%x,0x%x\n", mb[1], mb[2], mb[3]);
+               ql_log(ql_log_warn, vha, 0x0062,
+                   "Wrong product ID = 0x%x,0x%x,0x%x.\n",
+                   mb[1], mb[2], mb[3]);
 
                goto chip_diag_failed;
        }
@@ -1178,8 +1174,7 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
        if (IS_QLA2200(ha) &&
            RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) {
                /* Limit firmware transfer size with a 2200A */
-               DEBUG3(printk("scsi(%ld): Found QLA2200A chip.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_init, vha, 0x007e, "Found QLA2200A Chip.\n");
 
                ha->device_type |= DT_ISP2200A;
                ha->fw_transfer_size = 128;
@@ -1188,24 +1183,20 @@ qla2x00_chip_diag(scsi_qla_host_t *vha)
        /* Wrap Incoming Mailboxes Test. */
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
-       DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", vha->host_no));
+       ql_dbg(ql_dbg_init, vha, 0x007f, "Checking mailboxes.\n");
        rval = qla2x00_mbx_reg_test(vha);
-       if (rval) {
-               DEBUG(printk("scsi(%ld): Failed mailbox send register test\n",
-                   vha->host_no));
-               qla_printk(KERN_WARNING, ha,
-                   "Failed mailbox send register test\n");
-       }
-       else {
+       if (rval)
+               ql_log(ql_log_warn, vha, 0x0080,
+                   "Failed mailbox send register test.\n");
+       else
                /* Flag a successful rval */
                rval = QLA_SUCCESS;
-       }
        spin_lock_irqsave(&ha->hardware_lock, flags);
 
 chip_diag_failed:
        if (rval)
-               DEBUG2_3(printk("scsi(%ld): Chip diagnostics **** FAILED "
-                   "****\n", vha->host_no));
+               ql_log(ql_log_info, vha, 0x0081,
+                   "Chip diagnostics **** FAILED ****.\n");
 
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
@@ -1232,10 +1223,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha)
 
        rval = qla2x00_mbx_reg_test(vha);
        if (rval) {
-               DEBUG(printk("scsi(%ld): Failed mailbox send register test\n",
-                   vha->host_no));
-               qla_printk(KERN_WARNING, ha,
-                   "Failed mailbox send register test\n");
+               ql_log(ql_log_warn, vha, 0x0082,
+                   "Failed mailbox send register test.\n");
        } else {
                /* Flag a successful rval */
                rval = QLA_SUCCESS;
@@ -1257,8 +1246,8 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
        struct rsp_que *rsp = ha->rsp_q_map[0];
 
        if (ha->fw_dump) {
-               qla_printk(KERN_WARNING, ha,
-                   "Firmware dump previously allocated.\n");
+               ql_dbg(ql_dbg_init, vha, 0x00bd,
+                   "Firmware dump already allocated.\n");
                return;
        }
 
@@ -1288,8 +1277,9 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
                tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma,
                    GFP_KERNEL);
                if (!tc) {
-                       qla_printk(KERN_WARNING, ha, "Unable to allocate "
-                           "(%d KB) for FCE.\n", FCE_SIZE / 1024);
+                       ql_log(ql_log_warn, vha, 0x00be,
+                           "Unable to allocate (%d KB) for FCE.\n",
+                           FCE_SIZE / 1024);
                        goto try_eft;
                }
 
@@ -1297,16 +1287,15 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
                rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS,
                    ha->fce_mb, &ha->fce_bufs);
                if (rval) {
-                       qla_printk(KERN_WARNING, ha, "Unable to initialize "
-                           "FCE (%d).\n", rval);
+                       ql_log(ql_log_warn, vha, 0x00bf,
+                           "Unable to initialize FCE (%d).\n", rval);
                        dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc,
                            tc_dma);
                        ha->flags.fce_enabled = 0;
                        goto try_eft;
                }
-
-               qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n",
-                   FCE_SIZE / 1024);
+               ql_log(ql_log_info, vha, 0x00c0,
+                   "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024);
 
                fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE;
                ha->flags.fce_enabled = 1;
@@ -1317,23 +1306,23 @@ try_eft:
                tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
                    GFP_KERNEL);
                if (!tc) {
-                       qla_printk(KERN_WARNING, ha, "Unable to allocate "
-                           "(%d KB) for EFT.\n", EFT_SIZE / 1024);
+                       ql_log(ql_log_warn, vha, 0x00c1,
+                           "Unable to allocate (%d KB) for EFT.\n",
+                           EFT_SIZE / 1024);
                        goto cont_alloc;
                }
 
                memset(tc, 0, EFT_SIZE);
                rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS);
                if (rval) {
-                       qla_printk(KERN_WARNING, ha, "Unable to initialize "
-                           "EFT (%d).\n", rval);
+                       ql_log(ql_log_warn, vha, 0x00c2,
+                           "Unable to initialize EFT (%d).\n", rval);
                        dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
                            tc_dma);
                        goto cont_alloc;
                }
-
-               qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n",
-                   EFT_SIZE / 1024);
+               ql_log(ql_log_info, vha, 0x00c3,
+                   "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
 
                eft_size = EFT_SIZE;
                ha->eft_dma = tc_dma;
@@ -1350,8 +1339,9 @@ cont_alloc:
 
        ha->fw_dump = vmalloc(dump_size);
        if (!ha->fw_dump) {
-               qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for "
-                   "firmware dump!!!\n", dump_size / 1024);
+               ql_log(ql_log_warn, vha, 0x00c4,
+                   "Unable to allocate (%d KB) for firmware dump.\n",
+                   dump_size / 1024);
 
                if (ha->fce) {
                        dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
@@ -1368,8 +1358,8 @@ cont_alloc:
                }
                return;
        }
-       qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware dump...\n",
-           dump_size / 1024);
+       ql_log(ql_log_info, vha, 0x00c5,
+           "Allocated (%d KB) for firmware dump.\n", dump_size / 1024);
 
        ha->fw_dump_len = dump_size;
        ha->fw_dump->signature[0] = 'Q';
@@ -1398,23 +1388,21 @@ qla81xx_mpi_sync(scsi_qla_host_t *vha)
        int rval;
        uint16_t dc;
        uint32_t dw;
-       struct qla_hw_data *ha = vha->hw;
 
        if (!IS_QLA81XX(vha->hw))
                return QLA_SUCCESS;
 
        rval = qla2x00_write_ram_word(vha, 0x7c00, 1);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(qla_printk(KERN_WARNING, ha,
-                   "Sync-MPI: Unable to acquire semaphore.\n"));
+               ql_log(ql_log_warn, vha, 0x0105,
+                   "Unable to acquire semaphore.\n");
                goto done;
        }
 
        pci_read_config_word(vha->hw->pdev, 0x54, &dc);
        rval = qla2x00_read_ram_word(vha, 0x7a15, &dw);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(qla_printk(KERN_WARNING, ha,
-                   "Sync-MPI: Unable to read sync.\n"));
+               ql_log(ql_log_warn, vha, 0x0067, "Unable to read sync.\n");
                goto done_release;
        }
 
@@ -1426,15 +1414,14 @@ qla81xx_mpi_sync(scsi_qla_host_t *vha)
        dw |= dc;
        rval = qla2x00_write_ram_word(vha, 0x7a15, dw);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(qla_printk(KERN_WARNING, ha,
-                   "Sync-MPI: Unable to gain sync.\n"));
+               ql_log(ql_log_warn, vha, 0x0114, "Unable to gain sync.\n");
        }
 
 done_release:
        rval = qla2x00_write_ram_word(vha, 0x7c00, 0);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(qla_printk(KERN_WARNING, ha,
-                   "Sync-MPI: Unable to release semaphore.\n"));
+               ql_log(ql_log_warn, vha, 0x006d,
+                   "Unable to release semaphore.\n");
        }
 
 done:
@@ -1479,14 +1466,14 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
        /* Load firmware sequences */
        rval = ha->isp_ops->load_risc(vha, &srisc_address);
        if (rval == QLA_SUCCESS) {
-               DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC "
-                   "code.\n", vha->host_no));
+               ql_dbg(ql_dbg_init, vha, 0x00c9,
+                   "Verifying Checksum of loaded RISC code.\n");
 
                rval = qla2x00_verify_checksum(vha, srisc_address);
                if (rval == QLA_SUCCESS) {
                        /* Start firmware execution. */
-                       DEBUG(printk("scsi(%ld): Checksum OK, start "
-                           "firmware.\n", vha->host_no));
+                       ql_dbg(ql_dbg_init, vha, 0x00ca,
+                           "Starting firmware.\n");
 
                        rval = qla2x00_execute_fw(vha, srisc_address);
                        /* Retrieve firmware information. */
@@ -1522,9 +1509,9 @@ enable_82xx_npiv:
                                }
                        }
                } else {
-                       DEBUG2(printk(KERN_INFO
-                           "scsi(%ld): ISP Firmware failed checksum.\n",
-                           vha->host_no));
+                       ql_log(ql_log_fatal, vha, 0x00cd,
+                           "ISP Firmware failed checksum.\n");
+                       goto failed;
                }
        }
 
@@ -1549,7 +1536,7 @@ enable_82xx_npiv:
                        ha->flags.fac_supported = 1;
                        ha->fdt_block_size = size << 2;
                } else {
-                       qla_printk(KERN_ERR, ha,
+                       ql_log(ql_log_warn, vha, 0x00ce,
                            "Unsupported FAC firmware (%d.%02d.%02d).\n",
                            ha->fw_major_version, ha->fw_minor_version,
                            ha->fw_subminor_version);
@@ -1557,8 +1544,8 @@ enable_82xx_npiv:
        }
 failed:
        if (rval) {
-               DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n",
-                   vha->host_no));
+               ql_log(ql_log_fatal, vha, 0x00cf,
+                   "Setup chip ****FAILED****.\n");
        }
 
        return (rval);
@@ -1608,10 +1595,11 @@ qla2x00_update_fw_options(scsi_qla_host_t *vha)
                return;
 
        /* Serial Link options. */
-       DEBUG3(printk("scsi(%ld): Serial link options:\n",
-           vha->host_no));
-       DEBUG3(qla2x00_dump_buffer((uint8_t *)&ha->fw_seriallink_options,
-           sizeof(ha->fw_seriallink_options)));
+       ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0115,
+           "Serial link options.\n");
+       ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0109,
+           (uint8_t *)&ha->fw_seriallink_options,
+           sizeof(ha->fw_seriallink_options));
 
        ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
        if (ha->fw_seriallink_options[3] & BIT_2) {
@@ -1688,7 +1676,7 @@ qla24xx_update_fw_options(scsi_qla_host_t *vha)
            le16_to_cpu(ha->fw_seriallink_options24[2]),
            le16_to_cpu(ha->fw_seriallink_options24[3]));
        if (rval != QLA_SUCCESS) {
-               qla_printk(KERN_WARNING, ha,
+               ql_log(ql_log_warn, vha, 0x0104,
                    "Unable to update Serial Link options (%x).\n", rval);
        }
 }
@@ -1746,8 +1734,9 @@ qla24xx_config_rings(struct scsi_qla_host *vha)
                icb->rid = __constant_cpu_to_le16(rid);
                if (ha->flags.msix_enabled) {
                        msix = &ha->msix_entries[1];
-                       DEBUG2_17(printk(KERN_INFO
-                       "Registering vector 0x%x for base que\n", msix->entry));
+                       ql_dbg(ql_dbg_init, vha, 0x00fd,
+                           "Registering vector 0x%x for base que.\n",
+                           msix->entry);
                        icb->msix = cpu_to_le16(msix->entry);
                }
                /* Use alternate PCI bus number */
@@ -1764,8 +1753,8 @@ qla24xx_config_rings(struct scsi_qla_host *vha)
                        icb->firmware_options_2 &=
                                __constant_cpu_to_le32(~BIT_22);
                        ha->flags.disable_msix_handshake = 1;
-                       qla_printk(KERN_INFO, ha,
-                               "MSIX Handshake Disable Mode turned on\n");
+                       ql_dbg(ql_dbg_init, vha, 0x00fe,
+                           "MSIX Handshake Disable Mode turned on.\n");
                } else {
                        icb->firmware_options_2 |=
                                __constant_cpu_to_le32(BIT_22);
@@ -1850,7 +1839,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
        /* Update any ISP specific firmware options before initialization. */
        ha->isp_ops->update_fw_options(vha);
 
-       DEBUG(printk("scsi(%ld): Issue init firmware.\n", vha->host_no));
+       ql_dbg(ql_dbg_init, vha, 0x00d1, "Issue init firmware.\n");
 
        if (ha->flags.npiv_supported) {
                if (ha->operating_mode == LOOP)
@@ -1866,11 +1855,11 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
 
        rval = qla2x00_init_firmware(vha, ha->init_cb_size);
        if (rval) {
-               DEBUG2_3(printk("scsi(%ld): Init firmware **** FAILED ****.\n",
-                   vha->host_no));
+               ql_log(ql_log_fatal, vha, 0x00d2,
+                   "Init Firmware **** FAILED ****.\n");
        } else {
-               DEBUG3(printk("scsi(%ld): Init firmware -- success.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_init, vha, 0x00d3,
+                   "Init Firmware -- success.\n");
        }
 
        return (rval);
@@ -1913,10 +1902,8 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
 
        /* Wait for ISP to finish LIP */
        if (!vha->flags.init_done)
-               qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n");
-
-       DEBUG3(printk("scsi(%ld): Waiting for LIP to complete...\n",
-           vha->host_no));
+               ql_log(ql_log_info, vha, 0x801e,
+                   "Waiting for LIP to complete.\n");
 
        do {
                rval = qla2x00_get_firmware_state(vha, state);
@@ -1925,30 +1912,35 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
                                vha->device_flags &= ~DFLG_NO_CABLE;
                        }
                        if (IS_QLA84XX(ha) && state[0] != FSTATE_READY) {
-                               DEBUG16(printk("scsi(%ld): fw_state=%x "
-                                   "84xx=%x.\n", vha->host_no, state[0],
-                                   state[2]));
+                               ql_dbg(ql_dbg_taskm, vha, 0x801f,
+                                   "fw_state=%x 84xx=%x.\n", state[0],
+                                   state[2]);
                                if ((state[2] & FSTATE_LOGGED_IN) &&
                                     (state[2] & FSTATE_WAITING_FOR_VERIFY)) {
-                                       DEBUG16(printk("scsi(%ld): Sending "
-                                           "verify iocb.\n", vha->host_no));
+                                       ql_dbg(ql_dbg_taskm, vha, 0x8028,
+                                           "Sending verify iocb.\n");
 
                                        cs84xx_time = jiffies;
                                        rval = qla84xx_init_chip(vha);
-                                       if (rval != QLA_SUCCESS)
+                                       if (rval != QLA_SUCCESS) {
+                                               ql_log(ql_log_warn,
+                                                   vha, 0x8043,
+                                                   "Init chip failed.\n");
                                                break;
+                                       }
 
                                        /* Add time taken to initialize. */
                                        cs84xx_time = jiffies - cs84xx_time;
                                        wtime += cs84xx_time;
                                        mtime += cs84xx_time;
-                                       DEBUG16(printk("scsi(%ld): Increasing "
-                                           "wait time by %ld. New time %ld\n",
-                                           vha->host_no, cs84xx_time, wtime));
+                                       ql_dbg(ql_dbg_taskm, vha, 0x8042,
+                                           "Increasing wait time by %ld. "
+                                           "New time %ld.\n", cs84xx_time,
+                                           wtime);
                                }
                        } else if (state[0] == FSTATE_READY) {
-                               DEBUG(printk("scsi(%ld): F/W Ready - OK \n",
-                                   vha->host_no));
+                               ql_dbg(ql_dbg_taskm, vha, 0x8037,
+                                   "F/W Ready - OK.\n");
 
                                qla2x00_get_retry_cnt(vha, &ha->retry_count,
                                    &ha->login_timeout, &ha->r_a_tov);
@@ -1965,7 +1957,7 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
                                 * other than Wait for Login.
                                 */
                                if (time_after_eq(jiffies, mtime)) {
-                                       qla_printk(KERN_INFO, ha,
+                                       ql_log(ql_log_info, vha, 0x8038,
                                            "Cable is unplugged...\n");
 
                                        vha->device_flags |= DFLG_NO_CABLE;
@@ -1985,17 +1977,17 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
                /* Delay for a while */
                msleep(500);
 
-               DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n",
-                   vha->host_no, state[0], jiffies));
+               ql_dbg(ql_dbg_taskm, vha, 0x8039,
+                   "fw_state=%x curr time=%lx.\n", state[0], jiffies);
        } while (1);
 
-       DEBUG(printk("scsi(%ld): fw_state=%x (%x, %x, %x, %x) curr time=%lx.\n",
-           vha->host_no, state[0], state[1], state[2], state[3], state[4],
-           jiffies));
+       ql_dbg(ql_dbg_taskm, vha, 0x803a,
+           "fw_state=%x (%x, %x, %x, %x) " "curr time=%lx.\n", state[0],
+           state[1], state[2], state[3], state[4], jiffies);
 
        if (rval) {
-               DEBUG2_3(printk("scsi(%ld): Firmware ready **** FAILED ****.\n",
-                   vha->host_no));
+               ql_log(ql_log_warn, vha, 0x803b,
+                   "Firmware ready **** FAILED ****.\n");
        }
 
        return (rval);
@@ -2034,19 +2026,19 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
                if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) ||
                    IS_QLA8XXX_TYPE(ha) ||
                    (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) {
-                       DEBUG2(printk("%s(%ld) Loop is in a transition state\n",
-                           __func__, vha->host_no));
+                       ql_dbg(ql_dbg_disc, vha, 0x2008,
+                           "Loop is in a transition state.\n");
                } else {
-                       qla_printk(KERN_WARNING, ha,
-                           "ERROR -- Unable to get host loop ID.\n");
+                       ql_log(ql_log_warn, vha, 0x2009,
+                           "Unable to get host loop ID.\n");
                        set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
                }
                return (rval);
        }
 
        if (topo == 4) {
-               qla_printk(KERN_INFO, ha,
-                       "Cannot get topology - retrying.\n");
+               ql_log(ql_log_info, vha, 0x200a,
+                   "Cannot get topology - retrying.\n");
                return (QLA_FUNCTION_FAILED);
        }
 
@@ -2059,31 +2051,27 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
 
        switch (topo) {
        case 0:
-               DEBUG3(printk("scsi(%ld): HBA in NL topology.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x200b, "HBA in NL topology.\n");
                ha->current_topology = ISP_CFG_NL;
                strcpy(connect_type, "(Loop)");
                break;
 
        case 1:
-               DEBUG3(printk("scsi(%ld): HBA in FL topology.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x200c, "HBA in FL topology.\n");
                ha->switch_cap = sw_cap;
                ha->current_topology = ISP_CFG_FL;
                strcpy(connect_type, "(FL_Port)");
                break;
 
        case 2:
-               DEBUG3(printk("scsi(%ld): HBA in N P2P topology.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x200d, "HBA in N P2P topology.\n");
                ha->operating_mode = P2P;
                ha->current_topology = ISP_CFG_N;
                strcpy(connect_type, "(N_Port-to-N_Port)");
                break;
 
        case 3:
-               DEBUG3(printk("scsi(%ld): HBA in F P2P topology.\n",
-                   vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x200e, "HBA in F P2P topology.\n");
                ha->switch_cap = sw_cap;
                ha->operating_mode = P2P;
                ha->current_topology = ISP_CFG_F;
@@ -2091,9 +2079,8 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
                break;
 
        default:
-               DEBUG3(printk("scsi(%ld): HBA in unknown topology %x. "
-                   "Using NL.\n",
-                   vha->host_no, topo));
+               ql_dbg(ql_dbg_disc, vha, 0x200f,
+                   "HBA in unknown topology %x, using NL.\n", topo);
                ha->current_topology = ISP_CFG_NL;
                strcpy(connect_type, "(Loop)");
                break;
@@ -2106,14 +2093,16 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
        vha->d_id.b.al_pa = al_pa;
 
        if (!vha->flags.init_done)
-               qla_printk(KERN_INFO, ha,
-                   "Topology - %s, Host Loop address 0x%x\n",
+               ql_log(ql_log_info, vha, 0x2010,
+                   "Topology - %s, Host Loop address 0x%x.\n",
                    connect_type, vha->loop_id);
 
        if (rval) {
-               DEBUG2_3(printk("scsi(%ld): FAILED.\n", vha->host_no));
+               ql_log(ql_log_warn, vha, 0x2011,
+                   "%s FAILED\n", __func__);
        } else {
-               DEBUG3(printk("scsi(%ld): exiting normally.\n", vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x2012,
+                   "%s success\n", __func__);
        }
 
        return(rval);
@@ -2227,18 +2216,22 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
        for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++)
                chksum += *ptr++;
 
-       DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no));
-       DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
+       ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x010f,
+           "Contents of NVRAM.\n");
+       ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0110,
+           (uint8_t *)nv, ha->nvram_size);
 
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' ||
            nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) {
                /* Reset NVRAM data. */
-               qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
-                   "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
-                   nv->nvram_version);
-               qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
-                   "invalid -- WWPN) defaults.\n");
+               ql_log(ql_log_warn, vha, 0x0064,
+                   "Inconisistent NVRAM "
+                   "detected: checksum=0x%x id=%c version=0x%x.\n",
+                   chksum, nv->id[0], nv->nvram_version);
+               ql_log(ql_log_warn, vha, 0x0065,
+                   "Falling back to "
+                   "functioning (yet invalid -- WWPN) defaults.\n");
 
                /*
                 * Set default initialization control block.
@@ -2382,8 +2375,13 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
        /*
         * Set host adapter parameters.
         */
+
+       /*
+        * BIT_7 in the host-parameters section allows for modification to
+        * internal driver logging.
+        */
        if (nv->host_p[0] & BIT_7)
-               ql2xextended_error_logging = 1;
+               ql2xextended_error_logging = 0x7fffffff;
        ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
        /* Always load RISC code on non ISP2[12]00 chips. */
        if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
@@ -2488,10 +2486,7 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
                if (ha->zio_mode != QLA_ZIO_DISABLED) {
                        ha->zio_mode = QLA_ZIO_MODE_6;
 
-                       DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer "
-                           "delay (%d us).\n", vha->host_no, ha->zio_mode,
-                           ha->zio_timer * 100));
-                       qla_printk(KERN_INFO, ha,
+                       ql_log(ql_log_info, vha, 0x0068,
                            "ZIO mode %d enabled; timer delay (%d us).\n",
                            ha->zio_mode, ha->zio_timer * 100);
 
@@ -2502,8 +2497,8 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
        }
 
        if (rval) {
-               DEBUG2_3(printk(KERN_WARNING
-                   "scsi(%ld): NVRAM configuration failed!\n", vha->host_no));
+               ql_log(ql_log_warn, vha, 0x0069,
+                   "NVRAM configuration failed.\n");
        }
        return (rval);
 }
@@ -2574,15 +2569,15 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
        if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) {
                rval = qla2x00_configure_hba(vha);
                if (rval != QLA_SUCCESS) {
-                       DEBUG(printk("scsi(%ld): Unable to configure HBA.\n",
-                           vha->host_no));
+                       ql_dbg(ql_dbg_disc, vha, 0x2013,
+                           "Unable to configure HBA.\n");
                        return (rval);
                }
        }
 
        save_flags = flags = vha->dpc_flags;
-       DEBUG(printk("scsi(%ld): Configure loop -- dpc flags =0x%lx\n",
-           vha->host_no, flags));
+       ql_dbg(ql_dbg_disc, vha, 0x2014,
+           "Configure loop -- dpc flags = 0x%lx.\n", flags);
 
        /*
         * If we have both an RSCN and PORT UPDATE pending then handle them
@@ -2619,15 +2614,21 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
        }
 
        if (test_bit(LOCAL_LOOP_UPDATE, &flags)) {
-               if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+               if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) {
+                       ql_dbg(ql_dbg_disc, vha, 0x2015,
+                           "Loop resync needed, failing.\n");
                        rval = QLA_FUNCTION_FAILED;
+               }
                else
                        rval = qla2x00_configure_local_loop(vha);
        }
 
        if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) {
-               if (LOOP_TRANSITION(vha))
+               if (LOOP_TRANSITION(vha)) {
+                       ql_dbg(ql_dbg_disc, vha, 0x201e,
+                           "Needs RSCN update and loop transition.\n");
                        rval = QLA_FUNCTION_FAILED;
+               }
                else
                        rval = qla2x00_configure_fabric(vha);
        }
@@ -2638,16 +2639,17 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
                        rval = QLA_FUNCTION_FAILED;
                } else {
                        atomic_set(&vha->loop_state, LOOP_READY);
-
-                       DEBUG(printk("scsi(%ld): LOOP READY\n", vha->host_no));
+                       ql_dbg(ql_dbg_disc, vha, 0x2069,
+                           "LOOP READY.\n");
                }
        }
 
        if (rval) {
-               DEBUG2_3(printk("%s(%ld): *** FAILED ***\n",
-                   __func__, vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x206a,
+                   "%s *** FAILED ***.\n", __func__);
        } else {
-               DEBUG3(printk("%s: exiting normally\n", __func__));
+               ql_dbg(ql_dbg_disc, vha, 0x206b,
+                   "%s: exiting normally.\n", __func__);
        }
 
        /* Restore state if a resync event occurred during processing */
@@ -2695,8 +2697,10 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
        new_fcport = NULL;
        entries = MAX_FIBRE_DEVICES;
 
-       DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", vha->host_no));
-       DEBUG3(qla2x00_get_fcal_position_map(vha, NULL));
+       ql_dbg(ql_dbg_disc, vha, 0x2016,
+           "Getting FCAL position map.\n");
+       if (ql2xextended_error_logging & ql_dbg_disc)
+               qla2x00_get_fcal_position_map(vha, NULL);
 
        /* Get list of logged in devices. */
        memset(ha->gid_list, 0, GID_LIST_SIZE);
@@ -2705,14 +2709,17 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
        if (rval != QLA_SUCCESS)
                goto cleanup_allocation;
 
-       DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n",
-           vha->host_no, entries));
-       DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list,
-           entries * sizeof(struct gid_list_info)));
+       ql_dbg(ql_dbg_disc, vha, 0x2017,
+           "Entries in ID list (%d).\n", entries);
+       ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2075,
+           (uint8_t *)ha->gid_list,
+           entries * sizeof(struct gid_list_info));
 
        /* Allocate temporary fcport for any new fcports discovered. */
        new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
        if (new_fcport == NULL) {
+               ql_log(ql_log_warn, vha, 0x2018,
+                   "Memory allocation failed for fcport.\n");
                rval = QLA_MEMORY_ALLOC_FAILED;
                goto cleanup_allocation;
        }
@@ -2726,9 +2733,9 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
                    fcport->port_type != FCT_BROADCAST &&
                    (fcport->flags & FCF_FABRIC_DEVICE) == 0) {
 
-                       DEBUG(printk("scsi(%ld): Marking port lost, "
-                           "loop_id=0x%04x\n",
-                           vha->host_no, fcport->loop_id));
+                       ql_dbg(ql_dbg_disc, vha, 0x2019,
+                           "Marking port lost loop_id=0x%04x.\n",
+                           fcport->loop_id);
 
                        qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST);
                }
@@ -2769,12 +2776,12 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
                new_fcport->vp_idx = vha->vp_idx;
                rval2 = qla2x00_get_port_database(vha, new_fcport, 0);
                if (rval2 != QLA_SUCCESS) {
-                       DEBUG2(printk("scsi(%ld): Failed to retrieve fcport "
-                           "information -- get_port_database=%x, "
-                           "loop_id=0x%04x\n",
-                           vha->host_no, rval2, new_fcport->loop_id));
-                       DEBUG2(printk("scsi(%ld): Scheduling resync...\n",
-                           vha->host_no));
+                       ql_dbg(ql_dbg_disc, vha, 0x201a,
+                           "Failed to retrieve fcport information "
+                           "-- get_port_database=%x, loop_id=0x%04x.\n",
+                           rval2, new_fcport->loop_id);
+                       ql_dbg(ql_dbg_disc, vha, 0x201b,
+                           "Scheduling resync.\n");
                        set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
                        continue;
                }
@@ -2810,6 +2817,8 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
                        fcport = new_fcport;
                        new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
                        if (new_fcport == NULL) {
+                               ql_log(ql_log_warn, vha, 0x201c,
+                                   "Failed to allocate memory for fcport.\n");
                                rval = QLA_MEMORY_ALLOC_FAILED;
                                goto cleanup_allocation;
                        }
@@ -2828,8 +2837,8 @@ cleanup_allocation:
        kfree(new_fcport);
 
        if (rval != QLA_SUCCESS) {
-               DEBUG2(printk("scsi(%ld): Configure local loop error exit: "
-                   "rval=%x\n", vha->host_no, rval));
+               ql_dbg(ql_dbg_disc, vha, 0x201d,
+                   "Configure local loop error exit: rval=%x.\n", rval);
        }
 
        return (rval);
@@ -2858,27 +2867,27 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
        rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
            mb);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(printk("scsi(%ld): Unable to adjust iIDMA "
-                   "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x %04x.\n",
-                   vha->host_no, fcport->port_name[0], fcport->port_name[1],
+               ql_dbg(ql_dbg_disc, vha, 0x2004,
+                   "Unable to adjust iIDMA "
+                   "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x "
+                   "%04x.\n", fcport->port_name[0], fcport->port_name[1],
                    fcport->port_name[2], fcport->port_name[3],
                    fcport->port_name[4], fcport->port_name[5],
                    fcport->port_name[6], fcport->port_name[7], rval,
-                   fcport->fp_speed, mb[0], mb[1]));
+                   fcport->fp_speed, mb[0], mb[1]);
        } else {
                link_speed = link_speeds[LS_UNKNOWN];
                if (fcport->fp_speed < 5)
                        link_speed = link_speeds[fcport->fp_speed];
                else if (fcport->fp_speed == 0x13)
                        link_speed = link_speeds[5];
-               DEBUG2(qla_printk(KERN_INFO, ha,
-                   "iIDMA adjusted to %s GB/s on "
-                   "%02x%02x%02x%02x%02x%02x%02x%02x.\n",
-                   link_speed, fcport->port_name[0],
-                   fcport->port_name[1], fcport->port_name[2],
-                   fcport->port_name[3], fcport->port_name[4],
-                   fcport->port_name[5], fcport->port_name[6],
-                   fcport->port_name[7]));
+               ql_dbg(ql_dbg_disc, vha, 0x2005,
+                   "iIDMA adjusted to %s GB/s "
+                   "on %02x%02x%02x%02x%02x%02x%02x%02x.\n", link_speed,
+                   fcport->port_name[0], fcport->port_name[1],
+                   fcport->port_name[2], fcport->port_name[3],
+                   fcport->port_name[4], fcport->port_name[5],
+                   fcport->port_name[6], fcport->port_name[7]);
        }
 }
 
@@ -2887,7 +2896,6 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
 {
        struct fc_rport_identifiers rport_ids;
        struct fc_rport *rport;
-       struct qla_hw_data *ha = vha->hw;
        unsigned long flags;
 
        qla2x00_rport_del(fcport);
@@ -2899,8 +2907,8 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids);
        if (!rport) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to allocate fc remote port!\n");
+               ql_log(ql_log_warn, vha, 0x2006,
+                   "Unable to allocate fc remote port.\n");
                return;
        }
        spin_lock_irqsave(fcport->vha->host->host_lock, flags);
@@ -2975,8 +2983,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
                loop_id = SNS_FL_PORT;
        rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1);
        if (rval != QLA_SUCCESS) {
-               DEBUG2(printk("scsi(%ld): MBC_GET_PORT_NAME Failed, No FL "
-                   "Port\n", vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x201f,
+                   "MBX_GET_PORT_NAME failed, No FL Port.\n");
 
                vha->device_flags &= ~SWITCH_FOUND;
                return (QLA_SUCCESS);
@@ -3003,32 +3011,32 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
                ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff,
                    0xfc, mb, BIT_1 | BIT_0);
                if (mb[0] != MBS_COMMAND_COMPLETE) {
-                       DEBUG2(qla_printk(KERN_INFO, ha,
-                           "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x "
-                           "mb[2]=%x mb[6]=%x mb[7]=%x\n", loop_id,
-                           mb[0], mb[1], mb[2], mb[6], mb[7]));
+                       ql_dbg(ql_dbg_disc, vha, 0x2042,
+                           "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x "
+                           "mb[6]=%x mb[7]=%x.\n", loop_id, mb[0], mb[1],
+                           mb[2], mb[6], mb[7]);
                        return (QLA_SUCCESS);
                }
 
                if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) {
                        if (qla2x00_rft_id(vha)) {
                                /* EMPTY */
-                               DEBUG2(printk("scsi(%ld): Register FC-4 "
-                                   "TYPE failed.\n", vha->host_no));
+                               ql_dbg(ql_dbg_disc, vha, 0x2045,
+                                   "Register FC-4 TYPE failed.\n");
                        }
                        if (qla2x00_rff_id(vha)) {
                                /* EMPTY */
-                               DEBUG2(printk("scsi(%ld): Register FC-4 "
-                                   "Features failed.\n", vha->host_no));
+                               ql_dbg(ql_dbg_disc, vha, 0x2049,
+                                   "Register FC-4 Features failed.\n");
                        }
                        if (qla2x00_rnn_id(vha)) {
                                /* EMPTY */
-                               DEBUG2(printk("scsi(%ld): Register Node Name "
-                                   "failed.\n", vha->host_no));
+                               ql_dbg(ql_dbg_disc, vha, 0x204f,
+                                   "Register Node Name failed.\n");
                        } else if (qla2x00_rsnn_nn(vha)) {
                                /* EMPTY */
-                               DEBUG2(printk("scsi(%ld): Register Symbolic "
-                                   "Node Name failed.\n", vha->host_no));
+                               ql_dbg(ql_dbg_disc, vha, 0x2053,
+                                   "Register Symobilic Node Name failed.\n");
                        }
                }
 
@@ -3132,8 +3140,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
        }
 
        if (rval) {
-               DEBUG2(printk("scsi(%ld): Configure fabric error exit: "
-                   "rval=%d\n", vha->host_no, rval));
+               ql_dbg(ql_dbg_disc, vha, 0x2068,
+                   "Configure fabric error exit rval=%d.\n", rval);
        }
 
        return (rval);
@@ -3175,8 +3183,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
        swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_KERNEL);
        if (!swl) {
                /*EMPTY*/
-               DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback "
-                   "on GA_NXT\n", vha->host_no));
+               ql_dbg(ql_dbg_disc, vha, 0x2054,
+                   "GID_PT allocations failed, fallback on GA_NXT.\n");
        } else {
                if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) {
                        kfree(swl);
@@ -3201,6 +3209,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
        /* Allocate temporary fcport for any new fcports discovered. */
        new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
        if (new_fcport == NULL) {
+               ql_log(ql_log_warn, vha, 0x205e,
+                   "Failed to allocate memory for fcport.\n");
                kfree(swl);
                return (QLA_MEMORY_ALLOC_FAILED);
        }
@@ -3247,9 +3257,9 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
                        /* Send GA_NXT to the switch */
                        rval = qla2x00_ga_nxt(vha, new_fcport);
                        if (rval != QLA_SUCCESS) {
-                               qla_printk(KERN_WARNING, ha,
-                                   "SNS scan failed -- assuming zero-entry "
-                                   "result...\n");
+                               ql_log(ql_log_warn, vha, 0x2064,
+                                   "SNS scan failed -- assuming "
+                                   "zero-entry result.\n");
                                list_for_each_entry_safe(fcport, fcptemp,
                                    new_fcports, list) {
                                        list_del(&fcport->list);
@@ -3265,9 +3275,11 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
                        wrap.b24 = new_fcport->d_id.b24;
                        first_dev = 0;
                } else if (new_fcport->d_id.b24 == wrap.b24) {
-                       DEBUG2(printk("scsi(%ld): device wrap (%02x%02x%02x)\n",
-                           vha->host_no, new_fcport->d_id.b.domain,
-                           new_fcport->d_id.b.area, new_fcport->d_id.b.al_pa));
+                       ql_dbg(ql_dbg_disc, vha, 0x2065,
+                           "Device wrap (%02x%02x%02x).\n",
+                           new_fcport->d_id.b.domain,
+                           new_fcport->d_id.b.area,
+                           new_fcport->d_id.b.al_pa);
                        break;
                }
 
@@ -3372,6 +3384,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
                nxt_d_id.b24 = new_fcport->d_id.b24;
                new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
                if (new_fcport == NULL) {
+                       ql_log(ql_log_warn, vha, 0x2066,
+                           "Memory allocation failed for fcport.\n");
                        kfree(swl);
                        return (QLA_MEMORY_ALLOC_FAILED);
                }
@@ -3501,10 +3515,10 @@ qla2x00_device_resync(scsi_qla_host_t *vha)
                d_id.b.area = MSB(LSW(rscn_entry));
                d_id.b.al_pa = LSB(LSW(rscn_entry));
 
-               DEBUG(printk("scsi(%ld): RSCN queue entry[%d] = "
-                   "[%02x/%02x%02x%02x].\n",
-                   vha->host_no, vha->rscn_out_ptr, format, d_id.b.domain,
-                   d_id.b.area, d_id.b.al_pa));
+               ql_dbg(ql_dbg_disc, vha, 0x2020,
+                   "RSCN queue entry[%d] = [%02x/%02x%02x%02x].\n",
+                   vha->rscn_out_ptr, format, d_id.b.domain, d_id.b.area,
+                   d_id.b.al_pa);
 
                vha->rscn_out_ptr++;
                if (vha->rscn_out_ptr == MAX_RSCN_COUNT)
@@ -3520,17 +3534,17 @@ qla2x00_device_resync(scsi_qla_host_t *vha)
                        if (rscn_entry != vha->rscn_queue[rscn_out_iter])
                                break;
 
-                       DEBUG(printk("scsi(%ld): Skipping duplicate RSCN queue "
-                           "entry found at [%d].\n", vha->host_no,
-                           rscn_out_iter));
+                       ql_dbg(ql_dbg_disc, vha, 0x2021,
+                           "Skipping duplicate RSCN queue entry found at "
+                           "[%d].\n", rscn_out_iter);
 
                        vha->rscn_out_ptr = rscn_out_iter;
                }
 
                /* Queue overflow, set switch default case. */
                if (vha->flags.rscn_queue_overflow) {
-                       DEBUG(printk("scsi(%ld): device_resync: rscn "
-                           "overflow.\n", vha->host_no));
+                       ql_dbg(ql_dbg_disc, vha, 0x2022,
+                           "device_resync: rscn overflow.\n");
 
                        format = 3;
                        vha->flags.rscn_queue_overflow = 0;
@@ -3659,10 +3673,11 @@ qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport,
        tmp_loopid = 0;
 
        for (;;) {
-               DEBUG(printk("scsi(%ld): Trying Fabric Login w/loop id 0x%04x "
-                   "for port %02x%02x%02x.\n",
-                   vha->host_no, fcport->loop_id, fcport->d_id.b.domain,
-                   fcport->d_id.b.area, fcport->d_id.b.al_pa));
+               ql_dbg(ql_dbg_disc, vha, 0x2000,
+                   "Trying Fabric Login w/loop id 0x%04x for port "
+                   "%02x%02x%02x.\n",
+                   fcport->loop_id, fcport->d_id.b.domain,
+                   fcport->d_id.b.area, fcport->d_id.b.al_pa);
 
                /* Login fcport on switch. */
                ha->isp_ops->fabric_login(vha, fcport->loop_id,
@@ -3680,10 +3695,11 @@ qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport,
                        tmp_loopid = fcport->loop_id;
                        fcport->loop_id = mb[1];
 
-                       DEBUG(printk("Fabric Login: port in use - next "
-                           "loop id=0x%04x, port Id=%02x%02x%02x.\n",
+                       ql_dbg(ql_dbg_disc, vha, 0x2001,
+                           "Fabric Login: port in use - next loop "
+                           "id=0x%04x, port id= %02x%02x%02x.\n",
                            fcport->loop_id, fcport->d_id.b.domain,
-                           fcport->d_id.b.area, fcport->d_id.b.al_pa));
+                           fcport->d_id.b.area, fcport->d_id.b.al_pa);
 
                } else if (mb[0] == MBS_COMMAND_COMPLETE) {
                        /*
@@ -3744,11 +3760,11 @@ qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport,
                        /*
                         * unrecoverable / not handled error
                         */
-                       DEBUG2(printk("%s(%ld): failed=%x port_id=%02x%02x%02x "
-                           "loop_id=%x jiffies=%lx.\n",
-                           __func__, vha->host_no, mb[0],
-                           fcport->d_id.b.domain, fcport->d_id.b.area,
-                           fcport->d_id.b.al_pa, fcport->loop_id, jiffies));
+                       ql_dbg(ql_dbg_disc, vha, 0x2002,
+                           "Failed=%x port_id=%02x%02x%02x loop_id=%x "
+                           "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain,
+                           fcport->d_id.b.area, fcport->d_id.b.al_pa,
+                           fcport->loop_id, jiffies);
 
                        *next_loopid = fcport->loop_id;
                        ha->isp_ops->fabric_logout(vha, fcport->loop_id,
@@ -3852,7 +3868,8 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
                return (QLA_FUNCTION_FAILED);
 
        if (rval)
-               DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+               ql_dbg(ql_dbg_disc, vha, 0x206c,
+                   "%s *** FAILED ***.\n", __func__);
 
        return (rval);
 }
@@ -3929,8 +3946,8 @@ qla82xx_quiescent_state_cleanup(scsi_qla_host_t *vha)
        struct qla_hw_data *ha = vha->hw;
        struct scsi_qla_host *vp;
 
-       qla_printk(KERN_INFO, ha,
-                       "Performing ISP error recovery - ha= %p.\n", ha);
+       ql_dbg(ql_dbg_p3p, vha, 0xb002,
+           "Performing ISP error recovery - ha=%p.\n", ha);
 
        atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
        if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
@@ -3964,8 +3981,8 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
        clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
        ha->qla_stats.total_isp_aborts++;
 
-       qla_printk(KERN_INFO, ha,
-           "Performing ISP error recovery - ha= %p.\n", ha);
+       ql_log(ql_log_info, vha, 0x00af,
+           "Performing ISP error recovery - ha=%p.\n", ha);
 
        /* For ISP82XX, reset_chip is just disabling interrupts.
         * Driver waits for the completion of the commands.
@@ -4016,6 +4033,8 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
                /* Make sure for ISP 82XX IO DMA is complete */
                if (IS_QLA82XX(ha)) {
                        qla82xx_chip_reset_cleanup(vha);
+                       ql_log(ql_log_info, vha, 0x00b4,
+                           "Done chip reset cleanup.\n");
 
                        /* Done waiting for pending commands.
                         * Reset the online flag.
@@ -4097,7 +4116,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                                    ha->fce_dma, ha->fce_bufs, ha->fce_mb,
                                    &ha->fce_bufs);
                                if (rval) {
-                                       qla_printk(KERN_WARNING, ha,
+                                       ql_log(ql_log_warn, vha, 0x8033,
                                            "Unable to reinitialize FCE "
                                            "(%d).\n", rval);
                                        ha->flags.fce_enabled = 0;
@@ -4109,7 +4128,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                                rval = qla2x00_enable_eft_trace(vha,
                                    ha->eft_dma, EFT_NUM_BUFFERS);
                                if (rval) {
-                                       qla_printk(KERN_WARNING, ha,
+                                       ql_log(ql_log_warn, vha, 0x8034,
                                            "Unable to reinitialize EFT "
                                            "(%d).\n", rval);
                                }
@@ -4118,9 +4137,9 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                        vha->flags.online = 1;
                        if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
                                if (ha->isp_abort_cnt == 0) {
-                                       qla_printk(KERN_WARNING, ha,
-                                           "ISP error recovery failed - "
-                                           "board disabled\n");
+                                       ql_log(ql_log_fatal, vha, 0x8035,
+                                           "ISP error recover failed - "
+                                           "board disabled.\n");
                                        /*
                                         * The next call disables the board
                                         * completely.
@@ -4132,16 +4151,16 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                                        status = 0;
                                } else { /* schedule another ISP abort */
                                        ha->isp_abort_cnt--;
-                                       DEBUG(printk("qla%ld: ISP abort - "
-                                           "retry remaining %d\n",
-                                           vha->host_no, ha->isp_abort_cnt));
+                                       ql_dbg(ql_dbg_taskm, vha, 0x8020,
+                                           "ISP abort - retry remaining %d.\n",
+                                           ha->isp_abort_cnt);
                                        status = 1;
                                }
                        } else {
                                ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT;
-                               DEBUG(printk("qla2x00(%ld): ISP error recovery "
-                                   "- retrying (%d) more times\n",
-                                   vha->host_no, ha->isp_abort_cnt));
+                               ql_dbg(ql_dbg_taskm, vha, 0x8021,
+                                   "ISP error recovery - retrying (%d) "
+                                   "more times.\n", ha->isp_abort_cnt);
                                set_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
                                status = 1;
                        }
@@ -4150,9 +4169,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
        }
 
        if (!status) {
-               DEBUG(printk(KERN_INFO
-                               "qla2x00_abort_isp(%ld): succeeded.\n",
-                               vha->host_no));
+               ql_dbg(ql_dbg_taskm, vha, 0x8022, "%s succeeded.\n", __func__);
 
                spin_lock_irqsave(&ha->vport_slock, flags);
                list_for_each_entry(vp, &ha->vp_list, list) {
@@ -4169,8 +4186,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                spin_unlock_irqrestore(&ha->vport_slock, flags);
 
        } else {
-               qla_printk(KERN_INFO, ha,
-                       "qla2x00_abort_isp: **** FAILED ****\n");
+               ql_log(ql_log_warn, vha, 0x8023, "%s **** FAILED ****.\n");
        }
 
        return(status);
@@ -4211,8 +4227,8 @@ qla2x00_restart_isp(scsi_qla_host_t *vha)
 
                status = qla2x00_fw_ready(vha);
                if (!status) {
-                       DEBUG(printk("%s(): Start configure loop, "
-                           "status = %d\n", __func__, status));
+                       ql_dbg(ql_dbg_taskm, vha, 0x8031,
+                           "Start configure loop status = %d.\n", status);
 
                        /* Issue a marker after FW becomes ready. */
                        qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL);
@@ -4234,9 +4250,8 @@ qla2x00_restart_isp(scsi_qla_host_t *vha)
                if ((vha->device_flags & DFLG_NO_CABLE))
                        status = 0;
 
-               DEBUG(printk("%s(): Configure loop done, status = 0x%x\n",
-                               __func__,
-                               status));
+               ql_dbg(ql_dbg_taskm, vha, 0x8032,
+                   "Configure loop done, status = 0x%x.\n", status);
        }
        return (status);
 }
@@ -4256,13 +4271,13 @@ qla25xx_init_queues(struct qla_hw_data *ha)
                        rsp->options &= ~BIT_0;
                        ret = qla25xx_init_rsp_que(base_vha, rsp);
                        if (ret != QLA_SUCCESS)
-                               DEBUG2_17(printk(KERN_WARNING
-                                       "%s Rsp que:%d init failed\n", __func__,
-                                               rsp->id));
+                               ql_dbg(ql_dbg_init, base_vha, 0x00ff,
+                                   "%s Rsp que: %d init failed.\n",
+                                   __func__, rsp->id);
                        else
-                               DEBUG2_17(printk(KERN_INFO
-                                       "%s Rsp que:%d inited\n", __func__,
-                                               rsp->id));
+                               ql_dbg(ql_dbg_init, base_vha, 0x0100,
+                                   "%s Rsp que: %d inited.\n",
+                                   __func__, rsp->id);
                }
        }
        for (i = 1; i < ha->max_req_queues; i++) {
@@ -4272,13 +4287,13 @@ qla25xx_init_queues(struct qla_hw_data *ha)
                        req->options &= ~BIT_0;
                        ret = qla25xx_init_req_que(base_vha, req);
                        if (ret != QLA_SUCCESS)
-                               DEBUG2_17(printk(KERN_WARNING
-                                       "%s Req que:%d init failed\n", __func__,
-                                               req->id));
+                               ql_dbg(ql_dbg_init, base_vha, 0x0101,
+                                   "%s Req que: %d init failed.\n",
+                                   __func__, req->id);
                        else
-                               DEBUG2_17(printk(KERN_WARNING
-                                       "%s Req que:%d inited\n", __func__,
-                                               req->id));
+                               ql_dbg(ql_dbg_init, base_vha, 0x0102,
+                                   "%s Req que: %d inited.\n",
+                                   __func__, req->id);
                }
        }
        return ret;
@@ -4397,19 +4412,22 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
        for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
                chksum += le32_to_cpu(*dptr++);
 
-       DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no));
-       DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
+       ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x006a,
+           "Contents of NVRAM\n");
+       ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010d,
+           (uint8_t *)nv, ha->nvram_size);
 
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
            || nv->id[3] != ' ' ||
            nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) {
                /* Reset NVRAM data. */
-               qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
-                   "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
-                   le16_to_cpu(nv->nvram_version));
-               qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
-                   "invalid -- WWPN) defaults.\n");
+               ql_log(ql_log_warn, vha, 0x006b,
+                   "Inconisistent NVRAM detected: checksum=0x%x id=%c "
+                   "version=0x%x.\n", chksum, nv->id[0], nv->nvram_version);
+               ql_log(ql_log_warn, vha, 0x006c,
+                   "Falling back to functioning (yet invalid -- WWPN) "
+                   "defaults.\n");
 
                /*
                 * Set default initialization control block.
@@ -4587,10 +4605,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
        if (ha->zio_mode != QLA_ZIO_DISABLED) {
                ha->zio_mode = QLA_ZIO_MODE_6;
 
-               DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay "
-                   "(%d us).\n", vha->host_no, ha->zio_mode,
-                   ha->zio_timer * 100));
-               qla_printk(KERN_INFO, ha,
+               ql_log(ql_log_info, vha, 0x006f,
                    "ZIO mode %d enabled; timer delay (%d us).\n",
                    ha->zio_mode, ha->zio_timer * 100);
 
@@ -4601,8 +4616,8 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
        }
 
        if (rval) {
-               DEBUG2_3(printk(KERN_WARNING
-                   "scsi(%ld): NVRAM configuration failed!\n", vha->host_no));
+               ql_log(ql_log_warn, vha, 0x0070,
+                   "NVRAM configuration failed.\n");
        }
        return (rval);
 }
@@ -4620,8 +4635,8 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr,
        struct qla_hw_data *ha = vha->hw;
        struct req_que *req = ha->req_q_map[0];
 
-       qla_printk(KERN_INFO, ha,
-           "FW: Loading from flash (%x)...\n", faddr);
+       ql_dbg(ql_dbg_init, vha, 0x008b,
+           "Loading firmware from flash (%x).\n", faddr);
 
        rval = QLA_SUCCESS;
 
@@ -4637,11 +4652,12 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr,
            dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) ||
            (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 &&
                dcode[3] == 0)) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to verify integrity of flash firmware image!\n");
-               qla_printk(KERN_WARNING, ha,
-                   "Firmware data: %08x %08x %08x %08x!\n", dcode[0],
-                   dcode[1], dcode[2], dcode[3]);
+               ql_log(ql_log_fatal, vha, 0x008c,
+                   "Unable to verify the integrity of flash firmware "
+                   "image.\n");
+               ql_log(ql_log_fatal, vha, 0x008d,
+                   "Firmware data: %08x %08x %08x %08x.\n",
+                   dcode[0], dcode[1], dcode[2], dcode[3]);
 
                return QLA_FUNCTION_FAILED;
        }
@@ -4660,9 +4676,10 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr,
                        if (dlen > risc_size)
                                dlen = risc_size;
 
-                       DEBUG7(printk("scsi(%ld): Loading risc segment@ risc "
-                           "addr %x, number of dwords 0x%x, offset 0x%x.\n",
-                           vha->host_no, risc_addr, dlen, faddr));
+                       ql_dbg(ql_dbg_init, vha, 0x008e,
+                           "Loading risc segment@ risc addr %x "
+                           "number of dwords 0x%x offset 0x%x.\n",
+                           risc_addr, dlen, faddr);
 
                        qla24xx_read_flash_data(vha, dcode, faddr, dlen);
                        for (i = 0; i < dlen; i++)
@@ -4671,12 +4688,9 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr,
                        rval = qla2x00_load_ram(vha, req->dma, risc_addr,
                            dlen);
                        if (rval) {
-                               DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
-                                   "segment %d of firmware\n", vha->host_no,
-                                   fragment));
-                               qla_printk(KERN_WARNING, ha,
-                                   "[ERROR] Failed to load segment %d of "
-                                   "firmware\n", fragment);
+                               ql_log(ql_log_fatal, vha, 0x008f,
+                                   "Failed to load segment %d of firmware.\n",
+                                   fragment);
                                break;
                        }
 
@@ -4709,9 +4723,10 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
        /* Load firmware blob. */
        blob = qla2x00_request_firmware(vha);
        if (!blob) {
-               qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
-               qla_printk(KERN_ERR, ha, "Firmware images can be retrieved "
-                   "from: " QLA_FW_URL ".\n");
+               ql_log(ql_log_info, vha, 0x0083,
+                   "Fimware image unavailable.\n");
+               ql_log(ql_log_info, vha, 0x0084,
+                   "Firmware images can be retrieved from: "QLA_FW_URL ".\n");
                return QLA_FUNCTION_FAILED;
        }
 
@@ -4724,8 +4739,8 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
 
        /* Validate firmware image by checking version. */
        if (blob->fw->size < 8 * sizeof(uint16_t)) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to verify integrity of firmware image (%Zd)!\n",
+               ql_log(ql_log_fatal, vha, 0x0085,
+                   "Unable to verify integrity of firmware image (%Zd).\n",
                    blob->fw->size);
                goto fail_fw_integrity;
        }
@@ -4734,11 +4749,11 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
        if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff &&
            wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 &&
                wcode[2] == 0 && wcode[3] == 0)) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to verify integrity of firmware image!\n");
-               qla_printk(KERN_WARNING, ha,
-                   "Firmware data: %04x %04x %04x %04x!\n", wcode[0],
-                   wcode[1], wcode[2], wcode[3]);
+               ql_log(ql_log_fatal, vha, 0x0086,
+                   "Unable to verify integrity of firmware image.\n");
+               ql_log(ql_log_fatal, vha, 0x0087,
+                   "Firmware data: %04x %04x %04x %04x.\n",
+                   wcode[0], wcode[1], wcode[2], wcode[3]);
                goto fail_fw_integrity;
        }
 
@@ -4751,9 +4766,9 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                /* Validate firmware image size. */
                fwclen += risc_size * sizeof(uint16_t);
                if (blob->fw->size < fwclen) {
-                       qla_printk(KERN_WARNING, ha,
+                       ql_log(ql_log_fatal, vha, 0x0088,
                            "Unable to verify integrity of firmware image "
-                           "(%Zd)!\n", blob->fw->size);
+                           "(%Zd).\n", blob->fw->size);
                        goto fail_fw_integrity;
                }
 
@@ -4762,10 +4777,9 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                        wlen = (uint16_t)(ha->fw_transfer_size >> 1);
                        if (wlen > risc_size)
                                wlen = risc_size;
-
-                       DEBUG7(printk("scsi(%ld): Loading risc segment@ risc "
-                           "addr %x, number of words 0x%x.\n", vha->host_no,
-                           risc_addr, wlen));
+                       ql_dbg(ql_dbg_init, vha, 0x0089,
+                           "Loading risc segment@ risc addr %x number of "
+                           "words 0x%x.\n", risc_addr, wlen);
 
                        for (i = 0; i < wlen; i++)
                                wcode[i] = swab16(fwcode[i]);
@@ -4773,12 +4787,9 @@ qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                        rval = qla2x00_load_ram(vha, req->dma, risc_addr,
                            wlen);
                        if (rval) {
-                               DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
-                                   "segment %d of firmware\n", vha->host_no,
-                                   fragment));
-                               qla_printk(KERN_WARNING, ha,
-                                   "[ERROR] Failed to load segment %d of "
-                                   "firmware\n", fragment);
+                               ql_log(ql_log_fatal, vha, 0x008a,
+                                   "Failed to load segment %d of firmware.\n",
+                                   fragment);
                                break;
                        }
 
@@ -4814,15 +4825,17 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
        /* Load firmware blob. */
        blob = qla2x00_request_firmware(vha);
        if (!blob) {
-               qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
-               qla_printk(KERN_ERR, ha, "Firmware images can be retrieved "
-                   "from: " QLA_FW_URL ".\n");
+               ql_log(ql_log_warn, vha, 0x0090,
+                   "Fimware image unavailable.\n");
+               ql_log(ql_log_warn, vha, 0x0091,
+                   "Firmware images can be retrieved from: "
+                   QLA_FW_URL ".\n");
 
                return QLA_FUNCTION_FAILED;
        }
 
-       qla_printk(KERN_INFO, ha,
-           "FW: Loading via request-firmware...\n");
+       ql_log(ql_log_info, vha, 0x0092,
+           "Loading via request-firmware.\n");
 
        rval = QLA_SUCCESS;
 
@@ -4834,8 +4847,8 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
 
        /* Validate firmware image by checking version. */
        if (blob->fw->size < 8 * sizeof(uint32_t)) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to verify integrity of firmware image (%Zd)!\n",
+               ql_log(ql_log_fatal, vha, 0x0093,
+                   "Unable to verify integrity of firmware image (%Zd).\n",
                    blob->fw->size);
                goto fail_fw_integrity;
        }
@@ -4845,11 +4858,12 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
            dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) ||
            (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 &&
                dcode[3] == 0)) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to verify integrity of firmware image!\n");
-               qla_printk(KERN_WARNING, ha,
-                   "Firmware data: %08x %08x %08x %08x!\n", dcode[0],
-                   dcode[1], dcode[2], dcode[3]);
+               ql_log(ql_log_fatal, vha, 0x0094,
+                   "Unable to verify integrity of firmware image (%Zd).\n",
+                   blob->fw->size);
+               ql_log(ql_log_fatal, vha, 0x0095,
+                   "Firmware data: %08x %08x %08x %08x.\n",
+                   dcode[0], dcode[1], dcode[2], dcode[3]);
                goto fail_fw_integrity;
        }
 
@@ -4861,9 +4875,9 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                /* Validate firmware image size. */
                fwclen += risc_size * sizeof(uint32_t);
                if (blob->fw->size < fwclen) {
-                       qla_printk(KERN_WARNING, ha,
+                       ql_log(ql_log_fatal, vha, 0x0096,
                            "Unable to verify integrity of firmware image "
-                           "(%Zd)!\n", blob->fw->size);
+                           "(%Zd).\n", blob->fw->size);
 
                        goto fail_fw_integrity;
                }
@@ -4874,9 +4888,9 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                        if (dlen > risc_size)
                                dlen = risc_size;
 
-                       DEBUG7(printk("scsi(%ld): Loading risc segment@ risc "
-                           "addr %x, number of dwords 0x%x.\n", vha->host_no,
-                           risc_addr, dlen));
+                       ql_dbg(ql_dbg_init, vha, 0x0097,
+                           "Loading risc segment@ risc addr %x "
+                           "number of dwords 0x%x.\n", risc_addr, dlen);
 
                        for (i = 0; i < dlen; i++)
                                dcode[i] = swab32(fwcode[i]);
@@ -4884,12 +4898,9 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
                        rval = qla2x00_load_ram(vha, req->dma, risc_addr,
                            dlen);
                        if (rval) {
-                               DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
-                                   "segment %d of firmware\n", vha->host_no,
-                                   fragment));
-                               qla_printk(KERN_WARNING, ha,
-                                   "[ERROR] Failed to load segment %d of "
-                                   "firmware\n", fragment);
+                               ql_log(ql_log_fatal, vha, 0x0098,
+                                   "Failed to load segment %d of firmware.\n",
+                                   fragment);
                                break;
                        }
 
@@ -4953,14 +4964,13 @@ try_blob_fw:
        if (rval == QLA_SUCCESS || !ha->flt_region_gold_fw)
                return rval;
 
-       qla_printk(KERN_ERR, ha,
-           "FW: Attempting to fallback to golden firmware...\n");
+       ql_log(ql_log_info, vha, 0x0099,
+           "Attempting to fallback to golden firmware.\n");
        rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw);
        if (rval != QLA_SUCCESS)
                return rval;
 
-       qla_printk(KERN_ERR, ha,
-           "FW: Please update operational firmware...\n");
+       ql_log(ql_log_info, vha, 0x009a, "Update operational firmware.\n");
        ha->flags.running_gold_fw = 1;
 
        return rval;
@@ -4987,8 +4997,8 @@ qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha)
                        continue;
                if (qla2x00_setup_chip(vha) != QLA_SUCCESS)
                        continue;
-               qla_printk(KERN_INFO, ha,
-                   "Attempting retry of stop-firmware command...\n");
+               ql_log(ql_log_info, vha, 0x8015,
+                   "Attempting retry of stop-firmware command.\n");
                ret = qla2x00_stop_firmware(vha);
        }
 }
@@ -5023,10 +5033,10 @@ qla24xx_configure_vhba(scsi_qla_host_t *vha)
        /* Login to SNS first */
        ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, BIT_1);
        if (mb[0] != MBS_COMMAND_COMPLETE) {
-               DEBUG15(qla_printk(KERN_INFO, ha,
-                   "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x "
-                   "mb[2]=%x mb[6]=%x mb[7]=%x\n", NPH_SNS,
-                   mb[0], mb[1], mb[2], mb[6], mb[7]));
+               ql_dbg(ql_dbg_init, vha, 0x0103,
+                   "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x "
+                   "mb[6]=%x mb[7]=%x.\n",
+                   NPH_SNS, mb[0], mb[1], mb[2], mb[6], mb[7]);
                return (QLA_FUNCTION_FAILED);
        }
 
@@ -5146,19 +5156,23 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
        for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
                chksum += le32_to_cpu(*dptr++);
 
-       DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no));
-       DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
+       ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0111,
+           "Contents of NVRAM:\n");
+       ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0112,
+           (uint8_t *)nv, ha->nvram_size);
 
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
            || nv->id[3] != ' ' ||
            nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) {
                /* Reset NVRAM data. */
-               qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
-                   "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
+               ql_log(ql_log_info, vha, 0x0073,
+                   "Inconisistent NVRAM detected: checksum=0x%x id=%c "
+                   "version=0x%x.\n", chksum, nv->id[0],
                    le16_to_cpu(nv->nvram_version));
-               qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
-                   "invalid -- WWPN) defaults.\n");
+               ql_log(ql_log_info, vha, 0x0074,
+                   "Falling back to functioning (yet invalid -- WWPN) "
+                   "defaults.\n");
 
                /*
                 * Set default initialization control block.
@@ -5350,12 +5364,10 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
        if (ha->zio_mode != QLA_ZIO_DISABLED) {
                ha->zio_mode = QLA_ZIO_MODE_6;
 
-               DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay "
-                   "(%d us).\n", vha->host_no, ha->zio_mode,
-                   ha->zio_timer * 100));
-               qla_printk(KERN_INFO, ha,
+               ql_log(ql_log_info, vha, 0x0075,
                    "ZIO mode %d enabled; timer delay (%d us).\n",
-                   ha->zio_mode, ha->zio_timer * 100);
+                   ha->zio_mode,
+                   ha->zio_timer * 100);
 
                icb->firmware_options_2 |= cpu_to_le32(
                    (uint32_t)ha->zio_mode);
@@ -5364,8 +5376,8 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
        }
 
        if (rval) {
-               DEBUG2_3(printk(KERN_WARNING
-                   "scsi(%ld): NVRAM configuration failed!\n", vha->host_no));
+               ql_log(ql_log_warn, vha, 0x0076,
+                   "NVRAM configuration failed.\n");
        }
        return (rval);
 }
@@ -5388,9 +5400,8 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
 
                status = qla2x00_fw_ready(vha);
                if (!status) {
-                       qla_printk(KERN_INFO, ha,
-                       "%s(): Start configure loop, "
-                       "status = %d\n", __func__, status);
+                       ql_log(ql_log_info, vha, 0x803c,
+                           "Start configure loop, status =%d.\n", status);
 
                        /* Issue a marker after FW becomes ready. */
                        qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL);
@@ -5412,9 +5423,8 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
                if ((vha->device_flags & DFLG_NO_CABLE))
                        status = 0;
 
-               qla_printk(KERN_INFO, ha,
-                       "%s(): Configure loop done, status = 0x%x\n",
-                       __func__, status);
+               ql_log(ql_log_info, vha, 0x803d,
+                   "Configure loop done, status = 0x%x.\n", status);
        }
 
        if (!status) {
@@ -5450,9 +5460,9 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
                            ha->fce_dma, ha->fce_bufs, ha->fce_mb,
                            &ha->fce_bufs);
                        if (rval) {
-                               qla_printk(KERN_WARNING, ha,
-                                   "Unable to reinitialize FCE "
-                                   "(%d).\n", rval);
+                               ql_log(ql_log_warn, vha, 0x803e,
+                                   "Unable to reinitialize FCE (%d).\n",
+                                   rval);
                                ha->flags.fce_enabled = 0;
                        }
                }
@@ -5462,17 +5472,16 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
                        rval = qla2x00_enable_eft_trace(vha,
                            ha->eft_dma, EFT_NUM_BUFFERS);
                        if (rval) {
-                               qla_printk(KERN_WARNING, ha,
-                                   "Unable to reinitialize EFT "
-                                   "(%d).\n", rval);
+                               ql_log(ql_log_warn, vha, 0x803f,
+                                   "Unable to reinitialize EFT (%d).\n",
+                                   rval);
                        }
                }
        }
 
        if (!status) {
-               DEBUG(printk(KERN_INFO
-                       "qla82xx_restart_isp(%ld): succeeded.\n",
-                       vha->host_no));
+               ql_dbg(ql_dbg_taskm, vha, 0x8040,
+                   "qla82xx_restart_isp succeeded.\n");
 
                spin_lock_irqsave(&ha->vport_slock, flags);
                list_for_each_entry(vp, &ha->vp_list, list) {
@@ -5489,8 +5498,8 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
                spin_unlock_irqrestore(&ha->vport_slock, flags);
 
        } else {
-               qla_printk(KERN_INFO, ha,
-                       "qla82xx_restart_isp: **** FAILED ****\n");
+               ql_log(ql_log_warn, vha, 0x8041,
+                   "qla82xx_restart_isp **** FAILED ****.\n");
        }
 
        return status;
@@ -5640,9 +5649,8 @@ qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport)
        if (ret == QLA_SUCCESS)
                fcport->fcp_prio = priority;
        else
-               DEBUG2(printk(KERN_WARNING
-                       "scsi(%ld): Unable to activate fcp priority, "
-                       " ret=0x%x\n", vha->host_no, ret));
+               ql_dbg(ql_dbg_user, vha, 0x704f,
+                   "Unable to activate fcp priority, ret=0x%x.\n", ret);
 
        return  ret;
 }