aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@daterainc.com>2013-08-21 17:54:54 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-09-10 19:48:35 -0400
commitb3faa2e87ce04e48f16f3823977329b7c367b3f9 (patch)
tree796a8722df5ffa66e29936f5cfdf4624e536208a /drivers/scsi
parentcf6d1f0964fa9db57fc660caf51939d7a03359a1 (diff)
target/tcm_qla2xxx: Add/use target_reverse_dma_direction() in target_core_fabric.h
Reversing the dma_data_direction for pci_map_sg() friends is useful for other drivers, so move it from tcm_qla2xxx into inline code within target_core_fabric.h. Also drop internal usage of equivlient in tcm_qla2xxx fabric code. Reported-by: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Cc: Giridhar Malavali <giridhar.malavali@qlogic.com> Cc: Chad Dupuis <chad.dupuis@qlogic.com> Cc: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 6a93a9126a91..f790fcaf87d4 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -497,38 +497,13 @@ static u32 tcm_qla2xxx_sess_get_index(struct se_session *se_sess)
497 return 0; 497 return 0;
498} 498}
499 499
500/*
501 * The LIO target core uses DMA_TO_DEVICE to mean that data is going
502 * to the target (eg handling a WRITE) and DMA_FROM_DEVICE to mean
503 * that data is coming from the target (eg handling a READ). However,
504 * this is just the opposite of what we have to tell the DMA mapping
505 * layer -- eg when handling a READ, the HBA will have to DMA the data
506 * out of memory so it can send it to the initiator, which means we
507 * need to use DMA_TO_DEVICE when we map the data.
508 */
509static enum dma_data_direction tcm_qla2xxx_mapping_dir(struct se_cmd *se_cmd)
510{
511 if (se_cmd->se_cmd_flags & SCF_BIDI)
512 return DMA_BIDIRECTIONAL;
513
514 switch (se_cmd->data_direction) {
515 case DMA_TO_DEVICE:
516 return DMA_FROM_DEVICE;
517 case DMA_FROM_DEVICE:
518 return DMA_TO_DEVICE;
519 case DMA_NONE:
520 default:
521 return DMA_NONE;
522 }
523}
524
525static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd) 500static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)
526{ 501{
527 struct qla_tgt_cmd *cmd = container_of(se_cmd, 502 struct qla_tgt_cmd *cmd = container_of(se_cmd,
528 struct qla_tgt_cmd, se_cmd); 503 struct qla_tgt_cmd, se_cmd);
529 504
530 cmd->bufflen = se_cmd->data_length; 505 cmd->bufflen = se_cmd->data_length;
531 cmd->dma_data_direction = tcm_qla2xxx_mapping_dir(se_cmd); 506 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
532 507
533 cmd->sg_cnt = se_cmd->t_data_nents; 508 cmd->sg_cnt = se_cmd->t_data_nents;
534 cmd->sg = se_cmd->t_data_sg; 509 cmd->sg = se_cmd->t_data_sg;
@@ -664,7 +639,7 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)
664 struct qla_tgt_cmd, se_cmd); 639 struct qla_tgt_cmd, se_cmd);
665 640
666 cmd->bufflen = se_cmd->data_length; 641 cmd->bufflen = se_cmd->data_length;
667 cmd->dma_data_direction = tcm_qla2xxx_mapping_dir(se_cmd); 642 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
668 cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED); 643 cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
669 644
670 cmd->sg_cnt = se_cmd->t_data_nents; 645 cmd->sg_cnt = se_cmd->t_data_nents;
@@ -688,7 +663,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
688 cmd->sg = NULL; 663 cmd->sg = NULL;
689 cmd->sg_cnt = 0; 664 cmd->sg_cnt = 0;
690 cmd->offset = 0; 665 cmd->offset = 0;
691 cmd->dma_data_direction = tcm_qla2xxx_mapping_dir(se_cmd); 666 cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
692 cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED); 667 cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
693 668
694 if (se_cmd->data_direction == DMA_FROM_DEVICE) { 669 if (se_cmd->data_direction == DMA_FROM_DEVICE) {