Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] target: Convert TASK_ATTR to scsi_tcq.h definitions

This patch converts target core and follwing scsi-misc upstream fabric
modules to use include/scsi/scsi_tcq.h includes for SIMPLE, HEAD_OF_QUEUE
and ORDERED SCSI tasks instead of scsi/libsas.h with TASK_ATTR*

*) tcm_loop: Convert tcm_loop_allocate_core_cmd() + tcm_loop_device_reset() to
scsi_tcq.h
*) tcm_fc: Convert ft_send_cmd() from FCP_PTA_* to scsi_tcq.h

Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Signed-off-by: James Bottomley <jbottomley@parallels.com>

authored by

Nicholas Bellinger and committed by
James Bottomley
e66ecd50 d60b7a0f

+39 -20
+6 -6
drivers/target/loopback/tcm_loop.c
··· 31 31 #include <scsi/scsi_host.h> 32 32 #include <scsi/scsi_device.h> 33 33 #include <scsi/scsi_cmnd.h> 34 - #include <scsi/libsas.h> /* For TASK_ATTR_* */ 34 + #include <scsi/scsi_tcq.h> 35 35 36 36 #include <target/target_core_base.h> 37 37 #include <target/target_core_transport.h> ··· 95 95 if (sc->device->tagged_supported) { 96 96 switch (sc->tag) { 97 97 case HEAD_OF_QUEUE_TAG: 98 - sam_task_attr = TASK_ATTR_HOQ; 98 + sam_task_attr = MSG_HEAD_TAG; 99 99 break; 100 100 case ORDERED_QUEUE_TAG: 101 - sam_task_attr = TASK_ATTR_ORDERED; 101 + sam_task_attr = MSG_ORDERED_TAG; 102 102 break; 103 103 default: 104 - sam_task_attr = TASK_ATTR_SIMPLE; 104 + sam_task_attr = MSG_SIMPLE_TAG; 105 105 break; 106 106 } 107 107 } else 108 - sam_task_attr = TASK_ATTR_SIMPLE; 108 + sam_task_attr = MSG_SIMPLE_TAG; 109 109 110 110 /* 111 111 * Initialize struct se_cmd descriptor from target_core_mod infrastructure ··· 379 379 * Initialize struct se_cmd descriptor from target_core_mod infrastructure 380 380 */ 381 381 transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, 382 - DMA_NONE, TASK_ATTR_SIMPLE, 382 + DMA_NONE, MSG_SIMPLE_TAG, 383 383 &tl_cmd->tl_sense_buf[0]); 384 384 /* 385 385 * Allocate the LUN_RESET TMR
+2 -2
drivers/target/target_core_pscsi.c
··· 41 41 #include <scsi/scsi_device.h> 42 42 #include <scsi/scsi_cmnd.h> 43 43 #include <scsi/scsi_host.h> 44 - #include <scsi/libsas.h> /* For TASK_ATTR_* */ 44 + #include <scsi/scsi_tcq.h> 45 45 46 46 #include <target/target_core_base.h> 47 47 #include <target/target_core_device.h> ··· 911 911 * descriptor 912 912 */ 913 913 blk_execute_rq_nowait(pdv->pdv_sd->request_queue, NULL, pt->pscsi_req, 914 - (task->task_se_cmd->sam_task_attr == TASK_ATTR_HOQ), 914 + (task->task_se_cmd->sam_task_attr == MSG_HEAD_TAG), 915 915 pscsi_req_done); 916 916 917 917 return PYX_TRANSPORT_SENT_TO_TRANSPORT;
+11 -11
drivers/target/target_core_transport.c
··· 42 42 #include <net/tcp.h> 43 43 #include <scsi/scsi.h> 44 44 #include <scsi/scsi_cmnd.h> 45 - #include <scsi/libsas.h> /* For TASK_ATTR_* */ 45 + #include <scsi/scsi_tcq.h> 46 46 47 47 #include <target/target_core_base.h> 48 48 #include <target/target_core_device.h> ··· 1074 1074 * head of the struct se_device->execute_task_list, and task_prev 1075 1075 * after that for each subsequent task 1076 1076 */ 1077 - if (task->task_se_cmd->sam_task_attr == TASK_ATTR_HOQ) { 1077 + if (task->task_se_cmd->sam_task_attr == MSG_HEAD_TAG) { 1078 1078 list_add(&task->t_execute_list, 1079 1079 (task_prev != NULL) ? 1080 1080 &task_prev->t_execute_list : ··· 1873 1873 if (SE_DEV(cmd)->dev_task_attr_type != SAM_TASK_ATTR_EMULATED) 1874 1874 return 0; 1875 1875 1876 - if (cmd->sam_task_attr == TASK_ATTR_ACA) { 1876 + if (cmd->sam_task_attr == MSG_ACA_TAG) { 1877 1877 DEBUG_STA("SAM Task Attribute ACA" 1878 1878 " emulation is not supported\n"); 1879 1879 return -1; ··· 2517 2517 * Check for the existence of HEAD_OF_QUEUE, and if true return 1 2518 2518 * to allow the passed struct se_cmd list of tasks to the front of the list. 2519 2519 */ 2520 - if (cmd->sam_task_attr == TASK_ATTR_HOQ) { 2520 + if (cmd->sam_task_attr == MSG_HEAD_TAG) { 2521 2521 atomic_inc(&SE_DEV(cmd)->dev_hoq_count); 2522 2522 smp_mb__after_atomic_inc(); 2523 2523 DEBUG_STA("Added HEAD_OF_QUEUE for CDB:" ··· 2525 2525 T_TASK(cmd)->t_task_cdb[0], 2526 2526 cmd->se_ordered_id); 2527 2527 return 1; 2528 - } else if (cmd->sam_task_attr == TASK_ATTR_ORDERED) { 2528 + } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { 2529 2529 spin_lock(&SE_DEV(cmd)->ordered_cmd_lock); 2530 2530 list_add_tail(&cmd->se_ordered_list, 2531 2531 &SE_DEV(cmd)->ordered_cmd_list); ··· 3424 3424 * See spc4r17 section 5.3 3425 3425 */ 3426 3426 if (SE_DEV(cmd)->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 3427 - cmd->sam_task_attr = TASK_ATTR_HOQ; 3427 + cmd->sam_task_attr = MSG_HEAD_TAG; 3428 3428 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; 3429 3429 break; 3430 3430 case READ_BUFFER: ··· 3632 3632 * See spc4r17 section 5.3 3633 3633 */ 3634 3634 if (SE_DEV(cmd)->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) 3635 - cmd->sam_task_attr = TASK_ATTR_HOQ; 3635 + cmd->sam_task_attr = MSG_HEAD_TAG; 3636 3636 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_NONSG_IO_CDB; 3637 3637 break; 3638 3638 default: ··· 3790 3790 struct se_cmd *cmd_p, *cmd_tmp; 3791 3791 int new_active_tasks = 0; 3792 3792 3793 - if (cmd->sam_task_attr == TASK_ATTR_SIMPLE) { 3793 + if (cmd->sam_task_attr == MSG_SIMPLE_TAG) { 3794 3794 atomic_dec(&dev->simple_cmds); 3795 3795 smp_mb__after_atomic_dec(); 3796 3796 dev->dev_cur_ordered_id++; 3797 3797 DEBUG_STA("Incremented dev->dev_cur_ordered_id: %u for" 3798 3798 " SIMPLE: %u\n", dev->dev_cur_ordered_id, 3799 3799 cmd->se_ordered_id); 3800 - } else if (cmd->sam_task_attr == TASK_ATTR_HOQ) { 3800 + } else if (cmd->sam_task_attr == MSG_HEAD_TAG) { 3801 3801 atomic_dec(&dev->dev_hoq_count); 3802 3802 smp_mb__after_atomic_dec(); 3803 3803 dev->dev_cur_ordered_id++; 3804 3804 DEBUG_STA("Incremented dev_cur_ordered_id: %u for" 3805 3805 " HEAD_OF_QUEUE: %u\n", dev->dev_cur_ordered_id, 3806 3806 cmd->se_ordered_id); 3807 - } else if (cmd->sam_task_attr == TASK_ATTR_ORDERED) { 3807 + } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { 3808 3808 spin_lock(&dev->ordered_cmd_lock); 3809 3809 list_del(&cmd->se_ordered_list); 3810 3810 atomic_dec(&dev->dev_ordered_sync); ··· 3837 3837 new_active_tasks++; 3838 3838 3839 3839 spin_lock(&dev->delayed_cmd_lock); 3840 - if (cmd_p->sam_task_attr == TASK_ATTR_ORDERED) 3840 + if (cmd_p->sam_task_attr == MSG_ORDERED_TAG) 3841 3841 break; 3842 3842 } 3843 3843 spin_unlock(&dev->delayed_cmd_lock);
+19 -1
drivers/target/tcm_fc/tfc_cmd.c
··· 35 35 #include <scsi/scsi_host.h> 36 36 #include <scsi/scsi_device.h> 37 37 #include <scsi/scsi_cmnd.h> 38 + #include <scsi/scsi_tcq.h> 38 39 #include <scsi/libfc.h> 39 40 #include <scsi/fc_encode.h> 40 41 ··· 593 592 case FCP_CFL_WRDATA | FCP_CFL_RDDATA: 594 593 goto err; /* TBD not supported by tcm_fc yet */ 595 594 } 595 + /* 596 + * Locate the SAM Task Attr from fc_pri_ta 597 + */ 598 + switch (fcp->fc_pri_ta & FCP_PTA_MASK) { 599 + case FCP_PTA_HEADQ: 600 + task_attr = MSG_HEAD_TAG; 601 + break; 602 + case FCP_PTA_ORDERED: 603 + task_attr = MSG_ORDERED_TAG; 604 + break; 605 + case FCP_PTA_ACA: 606 + task_attr = MSG_ACA_TAG; 607 + break; 608 + case FCP_PTA_SIMPLE: /* Fallthrough */ 609 + default: 610 + task_attr = MSG_SIMPLE_TAG; 611 + } 596 612 597 - /* FCP_PTA_ maps 1:1 to TASK_ATTR_ */ 613 + 598 614 task_attr = fcp->fc_pri_ta & FCP_PTA_MASK; 599 615 data_len = ntohl(fcp->fc_dl); 600 616 cmd->cdb = fcp->fc_cdb;
+1
include/scsi/scsi_tcq.h
··· 9 9 #define MSG_SIMPLE_TAG 0x20 10 10 #define MSG_HEAD_TAG 0x21 11 11 #define MSG_ORDERED_TAG 0x22 12 + #define MSG_ACA_TAG 0x24 /* unsupported */ 12 13 13 14 #define SCSI_NO_TAG (-1) /* identify no tag in use */ 14 15