[SCSI] qla2xxx: Add ISP54xx support.
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / qla2xxx / qla_iocb.c
index ebdc3c54d155d0a35f6700f1b9e44651f0959015..8f0f4a298357c48d516160a6db822c5eb5789f73 100644 (file)
@@ -1,22 +1,9 @@
-/******************************************************************************
- *                  QLOGIC LINUX SOFTWARE
+/*
+ * QLogic Fibre Channel HBA Driver
+ * Copyright (c)  2003-2005 QLogic Corporation
  *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2005 QLogic Corporation
- * (www.qlogic.com)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- ******************************************************************************/
-
+ * See LICENSE.qla2xxx for copyright and licensing details.
+ */
 #include "qla_def.h"
 
 #include <linux/blkdev.h>
@@ -316,7 +303,6 @@ qla2x00_start_scsi(srb_t *sp)
        uint16_t        req_cnt;
        uint16_t        tot_dsds;
        struct device_reg_2xxx __iomem *reg;
-       char            tag[2];
 
        /* Setup device pointers. */
        ret = 0;
@@ -401,18 +387,6 @@ qla2x00_start_scsi(srb_t *sp)
 
        /* Update tagged queuing modifier */
        cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
-       if (scsi_populate_tag_msg(cmd, tag)) {
-               switch (tag[0]) {
-               case MSG_HEAD_TAG:
-                       cmd_pkt->control_flags =
-                           __constant_cpu_to_le16(CF_HEAD_TAG);
-                       break;
-               case MSG_ORDERED_TAG:
-                       cmd_pkt->control_flags =
-                           __constant_cpu_to_le16(CF_ORDERED_TAG);
-                       break;
-               }
-       }
 
        /* Load SCSI command packet. */
        memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len);
@@ -440,6 +414,11 @@ qla2x00_start_scsi(srb_t *sp)
        WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index);
        RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg));     /* PCI Posting. */
 
+       /* Manage unprocessed RIO/ZIO commands in response queue. */
+       if (ha->flags.process_response_queue &&
+           ha->response_ring_ptr->signature != RESPONSE_PROCESSED)
+               qla2x00_process_response_queue(ha);
+
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
        return (QLA_SUCCESS);
 
@@ -487,7 +466,7 @@ __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
        mrk->entry_type = MARKER_TYPE;
        mrk->modifier = type;
        if (type != MK_SYNC_ALL) {
-               if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
+               if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                        mrk24 = (struct mrk_entry_24xx *) mrk;
                        mrk24->nport_handle = cpu_to_le16(loop_id);
                        mrk24->lun[1] = LSB(lun);
@@ -540,7 +519,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
        for (timer = HZ; timer; timer--) {
                if ((req_cnt + 2) >= ha->req_q_cnt) {
                        /* Calculate number of free request entries. */
-                       if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
+                       if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
                                cnt = (uint16_t)RD_REG_DWORD(
                                    &reg->isp24.req_q_out);
                        else
@@ -614,7 +593,7 @@ qla2x00_isp_cmd(scsi_qla_host_t *ha)
                ha->request_ring_ptr++;
 
        /* Set chip new ring index. */
-       if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
+       if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                WRT_REG_DWORD(&reg->isp24.req_q_in, ha->req_ring_index);
                RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
        } else {
@@ -749,7 +728,6 @@ qla24xx_start_scsi(srb_t *sp)
        uint16_t        req_cnt;
        uint16_t        tot_dsds;
        struct device_reg_24xx __iomem *reg;
-       char            tag[2];
 
        /* Setup device pointers. */
        ret = 0;
@@ -810,12 +788,8 @@ qla24xx_start_scsi(srb_t *sp)
                        ha->req_q_cnt = ha->request_q_length -
                                (ha->req_ring_index - cnt);
        }
-       if (ha->req_q_cnt < (req_cnt + 2)) {
-               if  (cmd->use_sg)
-                       pci_unmap_sg(ha->pdev, sg, cmd->use_sg,
-                                       cmd->sc_data_direction);
+       if (ha->req_q_cnt < (req_cnt + 2))
                goto queuing_error;
-       }
 
        /* Build command packet. */
        ha->current_outstanding_cmd = handle;
@@ -828,6 +802,7 @@ qla24xx_start_scsi(srb_t *sp)
        cmd_pkt->handle = handle;
 
        /* Zero out remaining portion of packet. */
+       /*    tagged queuing modifier -- default is TSK_SIMPLE (0). */
        clr_ptr = (uint32_t *)cmd_pkt + 2;
        memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8);
        cmd_pkt->dseg_count = cpu_to_le16(tot_dsds);
@@ -838,20 +813,8 @@ qla24xx_start_scsi(srb_t *sp)
        cmd_pkt->port_id[1] = sp->fcport->d_id.b.area;
        cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain;
 
-       cmd_pkt->lun[1] = LSB(sp->cmd->device->lun);
-       cmd_pkt->lun[2] = MSB(sp->cmd->device->lun);
-
-       /* Update tagged queuing modifier -- default is TSK_SIMPLE (0). */
-       if (scsi_populate_tag_msg(cmd, tag)) {
-               switch (tag[0]) {
-               case MSG_HEAD_TAG:
-                       cmd_pkt->task = TSK_HEAD_OF_QUEUE;
-                       break;
-               case MSG_ORDERED_TAG:
-                       cmd_pkt->task = TSK_ORDERED;
-                       break;
-               }
-       }
+       int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun);
+       host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun));
 
        /* Load SCSI command packet. */
        memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len);
@@ -881,6 +844,11 @@ qla24xx_start_scsi(srb_t *sp)
        WRT_REG_DWORD(&reg->req_q_in, ha->req_ring_index);
        RD_REG_DWORD_RELAXED(&reg->req_q_in);           /* PCI Posting. */
 
+       /* Manage unprocessed RIO/ZIO commands in response queue. */
+       if (ha->flags.process_response_queue &&
+           ha->response_ring_ptr->signature != RESPONSE_PROCESSED)
+               qla24xx_process_response_queue(ha);
+
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
        return QLA_SUCCESS;