Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-2.6-microblaze.git] / drivers / scsi / qla2xxx / qla_iocb.c
index 0954fa4..93c2460 100644 (file)
@@ -594,6 +594,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
        uint32_t dsd_list_len;
        struct dsd_dma *dsd_ptr;
        struct ct6_dsd *ctx;
+       struct qla_qpair *qpair = sp->qpair;
 
        cmd = GET_CMD_SP(sp);
 
@@ -612,12 +613,12 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
                cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA);
-               vha->qla_stats.output_bytes += scsi_bufflen(cmd);
-               vha->qla_stats.output_requests++;
+               qpair->counters.output_bytes += scsi_bufflen(cmd);
+               qpair->counters.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA);
-               vha->qla_stats.input_bytes += scsi_bufflen(cmd);
-               vha->qla_stats.input_requests++;
+               qpair->counters.input_bytes += scsi_bufflen(cmd);
+               qpair->counters.input_requests++;
        }
 
        cur_seg = scsi_sglist(cmd);
@@ -704,6 +705,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
        struct scsi_cmnd *cmd;
        struct scatterlist *sg;
        int i;
+       struct qla_qpair *qpair = sp->qpair;
 
        cmd = GET_CMD_SP(sp);
 
@@ -721,12 +723,12 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
                cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_WRITE_DATA);
-               vha->qla_stats.output_bytes += scsi_bufflen(cmd);
-               vha->qla_stats.output_requests++;
+               qpair->counters.output_bytes += scsi_bufflen(cmd);
+               qpair->counters.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_READ_DATA);
-               vha->qla_stats.input_bytes += scsi_bufflen(cmd);
-               vha->qla_stats.input_requests++;
+               qpair->counters.input_bytes += scsi_bufflen(cmd);
+               qpair->counters.input_requests++;
        }
 
        /* One DSD is available in the Command Type 3 IOCB */
@@ -1635,6 +1637,12 @@ qla24xx_start_scsi(srb_t *sp)
 
        tot_dsds = nseg;
        req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
+
+       sp->iores.res_type = RESOURCE_INI;
+       sp->iores.iocb_cnt = req_cnt;
+       if (qla_get_iocbs(sp->qpair, &sp->iores))
+               goto queuing_error;
+
        if (req->cnt < (req_cnt + 2)) {
                cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
                    rd_reg_dword_relaxed(req->req_q_out);
@@ -1707,6 +1715,7 @@ queuing_error:
        if (tot_dsds)
                scsi_dma_unmap(cmd);
 
+       qla_put_iocbs(sp->qpair, &sp->iores);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
        return QLA_FUNCTION_FAILED;
@@ -1820,6 +1829,12 @@ qla24xx_dif_start_scsi(srb_t *sp)
        /* Total Data and protection sg segment(s) */
        tot_prot_dsds = nseg;
        tot_dsds += nseg;
+
+       sp->iores.res_type = RESOURCE_INI;
+       sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
+       if (qla_get_iocbs(sp->qpair, &sp->iores))
+               goto queuing_error;
+
        if (req->cnt < (req_cnt + 2)) {
                cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
                    rd_reg_dword_relaxed(req->req_q_out);
@@ -1894,6 +1909,7 @@ queuing_error:
        }
        /* Cleanup will be performed by the caller (queuecommand) */
 
+       qla_put_iocbs(sp->qpair, &sp->iores);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
        return QLA_FUNCTION_FAILED;
 }
@@ -1955,6 +1971,12 @@ qla2xxx_start_scsi_mq(srb_t *sp)
 
        tot_dsds = nseg;
        req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
+
+       sp->iores.res_type = RESOURCE_INI;
+       sp->iores.iocb_cnt = req_cnt;
+       if (qla_get_iocbs(sp->qpair, &sp->iores))
+               goto queuing_error;
+
        if (req->cnt < (req_cnt + 2)) {
                cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
                    rd_reg_dword_relaxed(req->req_q_out);
@@ -2027,6 +2049,7 @@ queuing_error:
        if (tot_dsds)
                scsi_dma_unmap(cmd);
 
+       qla_put_iocbs(sp->qpair, &sp->iores);
        spin_unlock_irqrestore(&qpair->qp_lock, flags);
 
        return QLA_FUNCTION_FAILED;
@@ -2155,6 +2178,12 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
        /* Total Data and protection sg segment(s) */
        tot_prot_dsds = nseg;
        tot_dsds += nseg;
+
+       sp->iores.res_type = RESOURCE_INI;
+       sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
+       if (qla_get_iocbs(sp->qpair, &sp->iores))
+               goto queuing_error;
+
        if (req->cnt < (req_cnt + 2)) {
                cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
                    rd_reg_dword_relaxed(req->req_q_out);
@@ -2232,6 +2261,7 @@ queuing_error:
        }
        /* Cleanup will be performed by the caller (queuecommand) */
 
+       qla_put_iocbs(sp->qpair, &sp->iores);
        spin_unlock_irqrestore(&qpair->qp_lock, flags);
        return QLA_FUNCTION_FAILED;
 }
@@ -2348,6 +2378,14 @@ qla24xx_prli_iocb(srb_t *sp, struct logio_entry_24xx *logio)
                if (sp->vha->flags.nvme_first_burst)
                        logio->io_parameter[0] =
                                cpu_to_le32(NVME_PRLI_SP_FIRST_BURST);
+               if (sp->vha->flags.nvme2_enabled) {
+                       /* Set service parameter BIT_8 for SLER support */
+                       logio->io_parameter[0] |=
+                               cpu_to_le32(NVME_PRLI_SP_SLER);
+                       /* Set service parameter BIT_9 for PI control support */
+                       logio->io_parameter[0] |=
+                               cpu_to_le32(NVME_PRLI_SP_PI_CTRL);
+               }
        }
 
        logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
@@ -2975,8 +3013,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
        memset(ptr, 0, sizeof(struct els_plogi_payload));
        memset(resp_ptr, 0, sizeof(struct els_plogi_payload));
        memcpy(elsio->u.els_plogi.els_plogi_pyld->data,
-           &ha->plogi_els_payld.data,
-           sizeof(elsio->u.els_plogi.els_plogi_pyld->data));
+           &ha->plogi_els_payld.fl_csp, LOGIN_TEMPLATE_SIZE);
 
        elsio->u.els_plogi.els_cmd = els_opcode;
        elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode;