aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_iocb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_iocb.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c90
1 files changed, 55 insertions, 35 deletions
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index eac950924497..70dbf53d9e0f 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -5,6 +5,7 @@
5 * See LICENSE.qla2xxx for copyright and licensing details. 5 * See LICENSE.qla2xxx for copyright and licensing details.
6 */ 6 */
7#include "qla_def.h" 7#include "qla_def.h"
8#include "qla_target.h"
8 9
9#include <linux/blkdev.h> 10#include <linux/blkdev.h>
10#include <linux/delay.h> 11#include <linux/delay.h>
@@ -23,18 +24,17 @@ qla2x00_get_cmd_direction(srb_t *sp)
23{ 24{
24 uint16_t cflags; 25 uint16_t cflags;
25 struct scsi_cmnd *cmd = GET_CMD_SP(sp); 26 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
27 struct scsi_qla_host *vha = sp->fcport->vha;
26 28
27 cflags = 0; 29 cflags = 0;
28 30
29 /* Set transfer direction */ 31 /* Set transfer direction */
30 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 32 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
31 cflags = CF_WRITE; 33 cflags = CF_WRITE;
32 sp->fcport->vha->hw->qla_stats.output_bytes += 34 vha->qla_stats.output_bytes += scsi_bufflen(cmd);
33 scsi_bufflen(cmd);
34 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 35 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
35 cflags = CF_READ; 36 cflags = CF_READ;
36 sp->fcport->vha->hw->qla_stats.input_bytes += 37 vha->qla_stats.input_bytes += scsi_bufflen(cmd);
37 scsi_bufflen(cmd);
38 } 38 }
39 return (cflags); 39 return (cflags);
40} 40}
@@ -385,9 +385,10 @@ qla2x00_start_scsi(srb_t *sp)
385 else 385 else
386 req->cnt = req->length - 386 req->cnt = req->length -
387 (req->ring_index - cnt); 387 (req->ring_index - cnt);
388 /* If still no head room then bail out */
389 if (req->cnt < (req_cnt + 2))
390 goto queuing_error;
388 } 391 }
389 if (req->cnt < (req_cnt + 2))
390 goto queuing_error;
391 392
392 /* Build command packet */ 393 /* Build command packet */
393 req->current_outstanding_cmd = handle; 394 req->current_outstanding_cmd = handle;
@@ -470,7 +471,7 @@ queuing_error:
470/** 471/**
471 * qla2x00_start_iocbs() - Execute the IOCB command 472 * qla2x00_start_iocbs() - Execute the IOCB command
472 */ 473 */
473static void 474void
474qla2x00_start_iocbs(struct scsi_qla_host *vha, struct req_que *req) 475qla2x00_start_iocbs(struct scsi_qla_host *vha, struct req_que *req)
475{ 476{
476 struct qla_hw_data *ha = vha->hw; 477 struct qla_hw_data *ha = vha->hw;
@@ -571,6 +572,29 @@ qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
571 return (ret); 572 return (ret);
572} 573}
573 574
575/*
576 * qla2x00_issue_marker
577 *
578 * Issue marker
579 * Caller CAN have hardware lock held as specified by ha_locked parameter.
580 * Might release it, then reaquire.
581 */
582int qla2x00_issue_marker(scsi_qla_host_t *vha, int ha_locked)
583{
584 if (ha_locked) {
585 if (__qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0,
586 MK_SYNC_ALL) != QLA_SUCCESS)
587 return QLA_FUNCTION_FAILED;
588 } else {
589 if (qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0,
590 MK_SYNC_ALL) != QLA_SUCCESS)
591 return QLA_FUNCTION_FAILED;
592 }
593 vha->marker_needed = 0;
594
595 return QLA_SUCCESS;
596}
597
574/** 598/**
575 * qla24xx_calc_iocbs() - Determine number of Command Type 3 and 599 * qla24xx_calc_iocbs() - Determine number of Command Type 3 and
576 * Continuation Type 1 IOCBs to allocate. 600 * Continuation Type 1 IOCBs to allocate.
@@ -629,11 +653,11 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
629 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 653 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
630 cmd_pkt->control_flags = 654 cmd_pkt->control_flags =
631 __constant_cpu_to_le16(CF_WRITE_DATA); 655 __constant_cpu_to_le16(CF_WRITE_DATA);
632 ha->qla_stats.output_bytes += scsi_bufflen(cmd); 656 vha->qla_stats.output_bytes += scsi_bufflen(cmd);
633 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 657 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
634 cmd_pkt->control_flags = 658 cmd_pkt->control_flags =
635 __constant_cpu_to_le16(CF_READ_DATA); 659 __constant_cpu_to_le16(CF_READ_DATA);
636 ha->qla_stats.input_bytes += scsi_bufflen(cmd); 660 vha->qla_stats.input_bytes += scsi_bufflen(cmd);
637 } 661 }
638 662
639 cur_seg = scsi_sglist(cmd); 663 cur_seg = scsi_sglist(cmd);
@@ -745,13 +769,11 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
745 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 769 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
746 cmd_pkt->task_mgmt_flags = 770 cmd_pkt->task_mgmt_flags =
747 __constant_cpu_to_le16(TMF_WRITE_DATA); 771 __constant_cpu_to_le16(TMF_WRITE_DATA);
748 sp->fcport->vha->hw->qla_stats.output_bytes += 772 vha->qla_stats.output_bytes += scsi_bufflen(cmd);
749 scsi_bufflen(cmd);
750 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 773 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
751 cmd_pkt->task_mgmt_flags = 774 cmd_pkt->task_mgmt_flags =
752 __constant_cpu_to_le16(TMF_READ_DATA); 775 __constant_cpu_to_le16(TMF_READ_DATA);
753 sp->fcport->vha->hw->qla_stats.input_bytes += 776 vha->qla_stats.input_bytes += scsi_bufflen(cmd);
754 scsi_bufflen(cmd);
755 } 777 }
756 778
757 /* One DSD is available in the Command Type 3 IOCB */ 779 /* One DSD is available in the Command Type 3 IOCB */
@@ -1245,7 +1267,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1245 return QLA_SUCCESS; 1267 return QLA_SUCCESS;
1246 } 1268 }
1247 1269
1248 cmd_pkt->vp_index = sp->fcport->vp_idx; 1270 cmd_pkt->vp_index = sp->fcport->vha->vp_idx;
1249 1271
1250 /* Set transfer direction */ 1272 /* Set transfer direction */
1251 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 1273 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
@@ -1502,9 +1524,9 @@ qla24xx_start_scsi(srb_t *sp)
1502 else 1524 else
1503 req->cnt = req->length - 1525 req->cnt = req->length -
1504 (req->ring_index - cnt); 1526 (req->ring_index - cnt);
1527 if (req->cnt < (req_cnt + 2))
1528 goto queuing_error;
1505 } 1529 }
1506 if (req->cnt < (req_cnt + 2))
1507 goto queuing_error;
1508 1530
1509 /* Build command packet. */ 1531 /* Build command packet. */
1510 req->current_outstanding_cmd = handle; 1532 req->current_outstanding_cmd = handle;
@@ -1527,7 +1549,7 @@ qla24xx_start_scsi(srb_t *sp)
1527 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; 1549 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa;
1528 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; 1550 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area;
1529 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; 1551 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain;
1530 cmd_pkt->vp_index = sp->fcport->vp_idx; 1552 cmd_pkt->vp_index = sp->fcport->vha->vp_idx;
1531 1553
1532 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); 1554 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun);
1533 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); 1555 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun));
@@ -1717,11 +1739,10 @@ qla24xx_dif_start_scsi(srb_t *sp)
1717 else 1739 else
1718 req->cnt = req->length - 1740 req->cnt = req->length -
1719 (req->ring_index - cnt); 1741 (req->ring_index - cnt);
1742 if (req->cnt < (req_cnt + 2))
1743 goto queuing_error;
1720 } 1744 }
1721 1745
1722 if (req->cnt < (req_cnt + 2))
1723 goto queuing_error;
1724
1725 status |= QDSS_GOT_Q_SPACE; 1746 status |= QDSS_GOT_Q_SPACE;
1726 1747
1727 /* Build header part of command packet (excluding the OPCODE). */ 1748 /* Build header part of command packet (excluding the OPCODE). */
@@ -1898,7 +1919,7 @@ qla24xx_login_iocb(srb_t *sp, struct logio_entry_24xx *logio)
1898 logio->port_id[0] = sp->fcport->d_id.b.al_pa; 1919 logio->port_id[0] = sp->fcport->d_id.b.al_pa;
1899 logio->port_id[1] = sp->fcport->d_id.b.area; 1920 logio->port_id[1] = sp->fcport->d_id.b.area;
1900 logio->port_id[2] = sp->fcport->d_id.b.domain; 1921 logio->port_id[2] = sp->fcport->d_id.b.domain;
1901 logio->vp_index = sp->fcport->vp_idx; 1922 logio->vp_index = sp->fcport->vha->vp_idx;
1902} 1923}
1903 1924
1904static void 1925static void
@@ -1922,7 +1943,7 @@ qla2x00_login_iocb(srb_t *sp, struct mbx_entry *mbx)
1922 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain); 1943 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain);
1923 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 | 1944 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 |
1924 sp->fcport->d_id.b.al_pa); 1945 sp->fcport->d_id.b.al_pa);
1925 mbx->mb9 = cpu_to_le16(sp->fcport->vp_idx); 1946 mbx->mb9 = cpu_to_le16(sp->fcport->vha->vp_idx);
1926} 1947}
1927 1948
1928static void 1949static void
@@ -1935,7 +1956,7 @@ qla24xx_logout_iocb(srb_t *sp, struct logio_entry_24xx *logio)
1935 logio->port_id[0] = sp->fcport->d_id.b.al_pa; 1956 logio->port_id[0] = sp->fcport->d_id.b.al_pa;
1936 logio->port_id[1] = sp->fcport->d_id.b.area; 1957 logio->port_id[1] = sp->fcport->d_id.b.area;
1937 logio->port_id[2] = sp->fcport->d_id.b.domain; 1958 logio->port_id[2] = sp->fcport->d_id.b.domain;
1938 logio->vp_index = sp->fcport->vp_idx; 1959 logio->vp_index = sp->fcport->vha->vp_idx;
1939} 1960}
1940 1961
1941static void 1962static void
@@ -1952,7 +1973,7 @@ qla2x00_logout_iocb(srb_t *sp, struct mbx_entry *mbx)
1952 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain); 1973 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain);
1953 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 | 1974 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 |
1954 sp->fcport->d_id.b.al_pa); 1975 sp->fcport->d_id.b.al_pa);
1955 mbx->mb9 = cpu_to_le16(sp->fcport->vp_idx); 1976 mbx->mb9 = cpu_to_le16(sp->fcport->vha->vp_idx);
1956 /* Implicit: mbx->mbx10 = 0. */ 1977 /* Implicit: mbx->mbx10 = 0. */
1957} 1978}
1958 1979
@@ -1962,7 +1983,7 @@ qla24xx_adisc_iocb(srb_t *sp, struct logio_entry_24xx *logio)
1962 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; 1983 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
1963 logio->control_flags = cpu_to_le16(LCF_COMMAND_ADISC); 1984 logio->control_flags = cpu_to_le16(LCF_COMMAND_ADISC);
1964 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); 1985 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
1965 logio->vp_index = sp->fcport->vp_idx; 1986 logio->vp_index = sp->fcport->vha->vp_idx;
1966} 1987}
1967 1988
1968static void 1989static void
@@ -1983,7 +2004,7 @@ qla2x00_adisc_iocb(srb_t *sp, struct mbx_entry *mbx)
1983 mbx->mb3 = cpu_to_le16(LSW(ha->async_pd_dma)); 2004 mbx->mb3 = cpu_to_le16(LSW(ha->async_pd_dma));
1984 mbx->mb6 = cpu_to_le16(MSW(MSD(ha->async_pd_dma))); 2005 mbx->mb6 = cpu_to_le16(MSW(MSD(ha->async_pd_dma)));
1985 mbx->mb7 = cpu_to_le16(LSW(MSD(ha->async_pd_dma))); 2006 mbx->mb7 = cpu_to_le16(LSW(MSD(ha->async_pd_dma)));
1986 mbx->mb9 = cpu_to_le16(sp->fcport->vp_idx); 2007 mbx->mb9 = cpu_to_le16(sp->fcport->vha->vp_idx);
1987} 2008}
1988 2009
1989static void 2010static void
@@ -2009,7 +2030,7 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
2009 tsk->port_id[0] = fcport->d_id.b.al_pa; 2030 tsk->port_id[0] = fcport->d_id.b.al_pa;
2010 tsk->port_id[1] = fcport->d_id.b.area; 2031 tsk->port_id[1] = fcport->d_id.b.area;
2011 tsk->port_id[2] = fcport->d_id.b.domain; 2032 tsk->port_id[2] = fcport->d_id.b.domain;
2012 tsk->vp_index = fcport->vp_idx; 2033 tsk->vp_index = fcport->vha->vp_idx;
2013 2034
2014 if (flags == TCF_LUN_RESET) { 2035 if (flags == TCF_LUN_RESET) {
2015 int_to_scsilun(lun, &tsk->lun); 2036 int_to_scsilun(lun, &tsk->lun);
@@ -2030,7 +2051,7 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
2030 els_iocb->handle = sp->handle; 2051 els_iocb->handle = sp->handle;
2031 els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); 2052 els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id);
2032 els_iocb->tx_dsd_count = __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt); 2053 els_iocb->tx_dsd_count = __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt);
2033 els_iocb->vp_index = sp->fcport->vp_idx; 2054 els_iocb->vp_index = sp->fcport->vha->vp_idx;
2034 els_iocb->sof_type = EST_SOFI3; 2055 els_iocb->sof_type = EST_SOFI3;
2035 els_iocb->rx_dsd_count = __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt); 2056 els_iocb->rx_dsd_count = __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt);
2036 2057
@@ -2160,7 +2181,7 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb)
2160 ct_iocb->handle = sp->handle; 2181 ct_iocb->handle = sp->handle;
2161 2182
2162 ct_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); 2183 ct_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id);
2163 ct_iocb->vp_index = sp->fcport->vp_idx; 2184 ct_iocb->vp_index = sp->fcport->vha->vp_idx;
2164 ct_iocb->comp_status = __constant_cpu_to_le16(0); 2185 ct_iocb->comp_status = __constant_cpu_to_le16(0);
2165 2186
2166 ct_iocb->cmd_dsd_count = 2187 ct_iocb->cmd_dsd_count =
@@ -2343,11 +2364,10 @@ sufficient_dsds:
2343 else 2364 else
2344 req->cnt = req->length - 2365 req->cnt = req->length -
2345 (req->ring_index - cnt); 2366 (req->ring_index - cnt);
2367 if (req->cnt < (req_cnt + 2))
2368 goto queuing_error;
2346 } 2369 }
2347 2370
2348 if (req->cnt < (req_cnt + 2))
2349 goto queuing_error;
2350
2351 ctx = sp->u.scmd.ctx = 2371 ctx = sp->u.scmd.ctx =
2352 mempool_alloc(ha->ctx_mempool, GFP_ATOMIC); 2372 mempool_alloc(ha->ctx_mempool, GFP_ATOMIC);
2353 if (!ctx) { 2373 if (!ctx) {
@@ -2362,7 +2382,7 @@ sufficient_dsds:
2362 if (!ctx->fcp_cmnd) { 2382 if (!ctx->fcp_cmnd) {
2363 ql_log(ql_log_fatal, vha, 0x3011, 2383 ql_log(ql_log_fatal, vha, 0x3011,
2364 "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd); 2384 "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd);
2365 goto queuing_error_fcp_cmnd; 2385 goto queuing_error;
2366 } 2386 }
2367 2387
2368 /* Initialize the DSD list and dma handle */ 2388 /* Initialize the DSD list and dma handle */
@@ -2400,7 +2420,7 @@ sufficient_dsds:
2400 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; 2420 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa;
2401 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; 2421 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area;
2402 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; 2422 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain;
2403 cmd_pkt->vp_index = sp->fcport->vp_idx; 2423 cmd_pkt->vp_index = sp->fcport->vha->vp_idx;
2404 2424
2405 /* Build IOCB segments */ 2425 /* Build IOCB segments */
2406 if (qla24xx_build_scsi_type_6_iocbs(sp, cmd_pkt, tot_dsds)) 2426 if (qla24xx_build_scsi_type_6_iocbs(sp, cmd_pkt, tot_dsds))
@@ -2489,7 +2509,7 @@ sufficient_dsds:
2489 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; 2509 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa;
2490 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; 2510 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area;
2491 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; 2511 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain;
2492 cmd_pkt->vp_index = sp->fcport->vp_idx; 2512 cmd_pkt->vp_index = sp->fcport->vha->vp_idx;
2493 2513
2494 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); 2514 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun);
2495 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, 2515 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun,