]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/qla2xxx/qla_iocb.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / scsi / qla2xxx / qla_iocb.c
index 6d2bd97c3b1133617ef22d494c16b537ab4bf44b..2258152b1f41bf8660b4351a2a5af8851ce09441 100644 (file)
@@ -160,7 +160,6 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
        struct scatterlist *sg;
        int i;
        struct req_que *req;
-       uint16_t que_id;
 
        cmd = sp->cmd;
 
@@ -174,9 +173,8 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
                return;
        }
 
-       vha = sp->vha;
-       que_id = vha->req_ques[0];
-       req = vha->hw->req_q_map[que_id];
+       vha = sp->fcport->vha;
+       req = sp->que;
 
        cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
 
@@ -223,7 +221,6 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
        struct scatterlist *sg;
        int i;
        struct req_que *req;
-       uint16_t que_id;
 
        cmd = sp->cmd;
 
@@ -237,9 +234,8 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
                return;
        }
 
-       vha = sp->vha;
-       que_id = vha->req_ques[0];
-       req = vha->hw->req_q_map[que_id];
+       vha = sp->fcport->vha;
+       req = sp->que;
 
        cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
 
@@ -298,7 +294,7 @@ qla2x00_start_scsi(srb_t *sp)
 
        /* Setup device pointers. */
        ret = 0;
-       vha = sp->vha;
+       vha = sp->fcport->vha;
        ha = vha->hw;
        reg = &ha->iobase->isp;
        cmd = sp->cmd;
@@ -357,7 +353,7 @@ qla2x00_start_scsi(srb_t *sp)
        /* Build command packet */
        req->current_outstanding_cmd = handle;
        req->outstanding_cmds[handle] = sp;
-       sp->vha = vha;
+       sp->que = req;
        sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
        req->cnt -= req_cnt;
 
@@ -573,6 +569,7 @@ qla2x00_isp_cmd(struct scsi_qla_host *vha, struct req_que *req)
 {
        struct qla_hw_data *ha = vha->hw;
        device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
+       struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp;
 
        DEBUG5(printk("%s(): IOCB data:\n", __func__));
        DEBUG5(qla2x00_dump_buffer(
@@ -587,8 +584,10 @@ qla2x00_isp_cmd(struct scsi_qla_host *vha, struct req_que *req)
                req->ring_ptr++;
 
        /* Set chip new ring index. */
-       if (ha->mqenable)
-               RD_REG_DWORD(&reg->isp25mq.req_q_out);
+       if (ha->mqenable) {
+               WRT_REG_DWORD(&reg->isp25mq.req_q_in, req->ring_index);
+               RD_REG_DWORD(&ioreg->hccr);
+       }
        else {
                if (IS_FWI2_CAPABLE(ha)) {
                        WRT_REG_DWORD(&reg->isp24.req_q_in, req->ring_index);
@@ -642,7 +641,6 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
        struct scsi_cmnd *cmd;
        struct scatterlist *sg;
        int i;
-       uint16_t que_id;
        struct req_que *req;
 
        cmd = sp->cmd;
@@ -657,9 +655,8 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
                return;
        }
 
-       vha = sp->vha;
-       que_id = vha->req_ques[0];
-       req = vha->hw->req_q_map[que_id];
+       vha = sp->fcport->vha;
+       req = sp->que;
 
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
@@ -725,9 +722,8 @@ qla24xx_start_scsi(srb_t *sp)
        struct req_que *req = NULL;
        struct rsp_que *rsp = NULL;
        struct scsi_cmnd *cmd = sp->cmd;
-       struct scsi_qla_host *vha = sp->vha;
+       struct scsi_qla_host *vha = sp->fcport->vha;
        struct qla_hw_data *ha = vha->hw;
-       device_reg_t __iomem *reg;
        uint16_t que_id;
 
        /* Setup device pointers. */
@@ -735,7 +731,7 @@ qla24xx_start_scsi(srb_t *sp)
        que_id = vha->req_ques[0];
 
        req = ha->req_q_map[que_id];
-       reg = ISP_QUE_REG(ha, req->id);
+       sp->que = req;
 
        if (req->rsp)
                rsp = req->rsp;
@@ -780,12 +776,7 @@ qla24xx_start_scsi(srb_t *sp)
 
        req_cnt = qla24xx_calc_iocbs(tot_dsds);
        if (req->cnt < (req_cnt + 2)) {
-               if (ha->mqenable)
-                       cnt = (uint16_t)
-                               RD_REG_DWORD_RELAXED(&reg->isp25mq.req_q_out);
-               else
-                       cnt = (uint16_t)
-                               RD_REG_DWORD_RELAXED(&reg->isp24.req_q_out);
+               cnt = ha->isp_ops->rd_req_reg(ha, req->id);
 
                if (req->ring_index < cnt)
                        req->cnt = cnt - req->ring_index;
@@ -799,7 +790,6 @@ qla24xx_start_scsi(srb_t *sp)
        /* Build command packet. */
        req->current_outstanding_cmd = handle;
        req->outstanding_cmds[handle] = sp;
-       sp->vha = vha;
        sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
        req->cnt -= req_cnt;
 
@@ -846,12 +836,7 @@ qla24xx_start_scsi(srb_t *sp)
        sp->flags |= SRB_DMA_VALID;
 
        /* Set chip new ring index. */
-       if (ha->mqenable)
-               WRT_REG_DWORD(&reg->isp25mq.req_q_in, req->ring_index);
-       else {
-               WRT_REG_DWORD(&reg->isp24.req_q_in, req->ring_index);
-               RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
-       }
+       ha->isp_ops->wrt_req_reg(ha, req->id, req->ring_index);
 
        /* Manage unprocessed RIO/ZIO commands in response queue. */
        if (vha->flags.process_response_queue &&
@@ -870,3 +855,34 @@ queuing_error:
        return QLA_FUNCTION_FAILED;
 }
 
+uint16_t
+qla24xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id)
+{
+       device_reg_t __iomem *reg = (void *) ha->iobase;
+       return RD_REG_DWORD_RELAXED(&reg->isp24.req_q_out);
+}
+
+uint16_t
+qla25xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id)
+{
+       device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id;
+       return RD_REG_DWORD_RELAXED(&reg->isp25mq.req_q_out);
+}
+
+void
+qla24xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
+{
+       device_reg_t __iomem *reg = (void *) ha->iobase;
+       WRT_REG_DWORD(&reg->isp24.req_q_in, index);
+       RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
+}
+
+void
+qla25xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index)
+{
+       device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id;
+       struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp;
+       WRT_REG_DWORD(&reg->isp25mq.req_q_in, index);
+       RD_REG_DWORD(&ioreg->hccr); /* PCI posting */
+}
+