[SCSI] qla2xxx: Correctly read sfp single byte mailbox register.
[pandora-kernel.git] / drivers / scsi / qla2xxx / qla_mbx.c
index e473e9f..aab628b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * QLogic Fibre Channel HBA Driver
- * Copyright (c)  2003-2010 QLogic Corporation
+ * Copyright (c)  2003-2011 QLogic Corporation
  *
  * See LICENSE.qla2xxx for copyright and licensing details.
  */
@@ -71,6 +71,13 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                return QLA_FUNCTION_TIMEOUT;
        }
 
+       if (ha->flags.isp82xx_fw_hung) {
+               /* Setting Link-Down error */
+               mcp->mb[0] = MBS_LINK_DOWN_ERROR;
+               rval = QLA_FUNCTION_FAILED;
+               goto premature_exit;
+       }
+
        /*
         * Wait for active mailbox commands to finish by waiting at most tov
         * seconds. This is to serialize actual issuing of mailbox cmds during
@@ -83,13 +90,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                return QLA_FUNCTION_TIMEOUT;
        }
 
-       if (IS_QLA82XX(ha) && ha->flags.fw_hung) {
-               /* Setting Link-Down error */
-               mcp->mb[0] = MBS_LINK_DOWN_ERROR;
-               rval = QLA_FUNCTION_FAILED;
-               goto premature_exit;
-       }
-
        ha->flags.mbox_busy = 1;
        /* Save mailbox command for debug */
        ha->mcp = mcp;
@@ -223,7 +223,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                ha->flags.mbox_int = 0;
                clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
 
-               if (IS_QLA82XX(ha) && ha->flags.fw_hung) {
+               if (ha->flags.isp82xx_fw_hung) {
                        ha->flags.mbox_busy = 0;
                        /* Setting Link-Down error */
                        mcp->mb[0] = MBS_LINK_DOWN_ERROR;
@@ -303,7 +303,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                            !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
 
                                qla_printk(KERN_WARNING, ha,
-                                   "Mailbox command timeout occured. "
+                                   "Mailbox command timeout occurred. "
                                    "Scheduling ISP " "abort. eeh_busy: 0x%x\n",
                                    ha->flags.eeh_busy);
                                set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
@@ -321,7 +321,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                            !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
 
                                qla_printk(KERN_WARNING, ha,
-                                   "Mailbox command timeout occured. "
+                                   "Mailbox command timeout occurred. "
                                    "Issuing ISP abort.\n");
 
                                set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
@@ -1261,11 +1261,12 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
                /* Check for logged in state. */
                if (pd24->current_login_state != PDS_PRLI_COMPLETE &&
                    pd24->last_login_state != PDS_PRLI_COMPLETE) {
-                       DEBUG2(printk("%s(%ld): Unable to verify "
-                           "login-state (%x/%x) for loop_id %x\n",
-                           __func__, vha->host_no,
-                           pd24->current_login_state,
-                           pd24->last_login_state, fcport->loop_id));
+                       DEBUG2(qla_printk(KERN_WARNING, ha,
+                          "scsi(%ld): Unable to verify login-state (%x/%x) "
+                          " - portid=%02x%02x%02x.\n", vha->host_no,
+                          pd24->current_login_state, pd24->last_login_state,
+                          fcport->d_id.b.domain, fcport->d_id.b.area,
+                          fcport->d_id.b.al_pa));
                        rval = QLA_FUNCTION_FAILED;
                        goto gpd_error_out;
                }
@@ -1289,6 +1290,12 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
                /* Check for logged in state. */
                if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
                    pd->slave_state != PD_STATE_PORT_LOGGED_IN) {
+                       DEBUG2(qla_printk(KERN_WARNING, ha,
+                          "scsi(%ld): Unable to verify login-state (%x/%x) "
+                          " - portid=%02x%02x%02x.\n", vha->host_no,
+                          pd->master_state, pd->slave_state,
+                          fcport->d_id.b.domain, fcport->d_id.b.area,
+                          fcport->d_id.b.al_pa));
                        rval = QLA_FUNCTION_FAILED;
                        goto gpd_error_out;
                }
@@ -1883,7 +1890,8 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
        lg->handle = MAKE_HANDLE(req->id, lg->handle);
        lg->nport_handle = cpu_to_le16(loop_id);
        lg->control_flags =
-           __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
+           __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO|
+               LCF_FREE_NPORT);
        lg->port_id[0] = al_pa;
        lg->port_id[1] = area;
        lg->port_id[2] = domain;
@@ -2362,7 +2370,7 @@ qla24xx_abort_command(srb_t *sp)
        abt->entry_count = 1;
        abt->handle = MAKE_HANDLE(req->id, abt->handle);
        abt->nport_handle = cpu_to_le16(fcport->loop_id);
-       abt->handle_to_abort = handle;
+       abt->handle_to_abort = MAKE_HANDLE(req->id, handle);
        abt->port_id[0] = fcport->d_id.b.al_pa;
        abt->port_id[1] = fcport->d_id.b.area;
        abt->port_id[2] = fcport->d_id.b.domain;
@@ -2462,22 +2470,19 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
                    "-- completion status (%x).\n", __func__,
                    vha->host_no, le16_to_cpu(sts->comp_status)));
                rval = QLA_FUNCTION_FAILED;
-       } else if (!(le16_to_cpu(sts->scsi_status) &
-           SS_RESPONSE_INFO_LEN_VALID)) {
-               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
-                   "-- no response info (%x).\n", __func__, vha->host_no,
-                   le16_to_cpu(sts->scsi_status)));
-               rval = QLA_FUNCTION_FAILED;
-       } else if (le32_to_cpu(sts->rsp_data_len) < 4) {
-               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
-                   "-- not enough response info (%d).\n", __func__,
-                   vha->host_no, le32_to_cpu(sts->rsp_data_len)));
-               rval = QLA_FUNCTION_FAILED;
-       } else if (sts->data[3]) {
-               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
-                   "-- response (%x).\n", __func__,
-                   vha->host_no, sts->data[3]));
-               rval = QLA_FUNCTION_FAILED;
+       } else if (le16_to_cpu(sts->scsi_status) &
+           SS_RESPONSE_INFO_LEN_VALID) {
+               if (le32_to_cpu(sts->rsp_data_len) < 4) {
+                       DEBUG2_3_11(printk("%s(%ld): ignoring inconsistent "
+                           "data length -- not enough response info (%d).\n",
+                           __func__, vha->host_no,
+                           le32_to_cpu(sts->rsp_data_len)));
+               } else if (sts->data[3]) {
+                       DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
+                           "-- response (%x).\n", __func__,
+                           vha->host_no, sts->data[3]));
+                       rval = QLA_FUNCTION_FAILED;
+               }
        }
 
        /* Issue marker IOCB. */
@@ -3603,14 +3608,14 @@ qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
        mcp->mb[9] = adr;
        mcp->mb[10] = opt;
        mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
-       mcp->in_mb = MBX_0;
+       mcp->in_mb = MBX_1|MBX_0;
        mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(vha, mcp);
 
        if (opt & BIT_0)
                if (sfp)
-                       *sfp = mcp->mb[8];
+                       *sfp = mcp->mb[1];
 
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
@@ -3792,7 +3797,7 @@ qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq,
        mcp->mb[20] = LSW(MSD(mreq->send_dma));
        mcp->mb[21] = MSW(MSD(mreq->send_dma));
 
-       /* recieve data address */
+       /* receive data address */
        mcp->mb[16] = LSW(mreq->rcv_dma);
        mcp->mb[17] = MSW(mreq->rcv_dma);
        mcp->mb[6] = LSW(MSD(mreq->rcv_dma));