aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-10-12 11:09:13 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-10-23 23:21:15 -0400
commitb937d27052e5759b1308782166fe47bc76e05b4d (patch)
treeeb5a99096bb695d208b5cacd27637c167e9bb8f5 /drivers/target
parent485fd0d1e3b8010b538bd0b209f3592acc825677 (diff)
target: remove the ->transport_split_cdb callback in se_cmd
Add a switch statement implementing the CDB LBA/len update directly in target_get_task_cdb and remove the old ->transport_split_cdb callback and all its implementations. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/Makefile1
-rw-r--r--drivers/target/target_core_cdb.c39
-rw-r--r--drivers/target/target_core_scdb.c105
-rw-r--r--drivers/target/target_core_scdb.h10
-rw-r--r--drivers/target/target_core_transport.c11
5 files changed, 36 insertions, 130 deletions
diff --git a/drivers/target/Makefile b/drivers/target/Makefile
index 1060c7b7f803..62e54053bcd8 100644
--- a/drivers/target/Makefile
+++ b/drivers/target/Makefile
@@ -6,7 +6,6 @@ target_core_mod-y := target_core_configfs.o \
6 target_core_hba.o \ 6 target_core_hba.o \
7 target_core_pr.o \ 7 target_core_pr.o \
8 target_core_alua.o \ 8 target_core_alua.o \
9 target_core_scdb.o \
10 target_core_tmr.o \ 9 target_core_tmr.o \
11 target_core_tpg.o \ 10 target_core_tpg.o \
12 target_core_transport.o \ 11 target_core_transport.o \
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index fb0b6308038b..575cf7216f52 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1273,11 +1273,44 @@ transport_emulate_control_cdb(struct se_task *task)
1273void target_get_task_cdb(struct se_task *task, unsigned char *cdb) 1273void target_get_task_cdb(struct se_task *task, unsigned char *cdb)
1274{ 1274{
1275 struct se_cmd *cmd = task->task_se_cmd; 1275 struct se_cmd *cmd = task->task_se_cmd;
1276 unsigned int cdb_len = scsi_command_size(cmd->t_task_cdb);
1276 1277
1277 memcpy(cdb, cmd->t_task_cdb, scsi_command_size(cmd->t_task_cdb)); 1278 memcpy(cdb, cmd->t_task_cdb, cdb_len);
1278 if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { 1279 if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
1279 cmd->transport_split_cdb(task->task_lba, task->task_sectors, 1280 unsigned long long lba = task->task_lba;
1280 cdb); 1281 u32 sectors = task->task_sectors;
1282
1283 switch (cdb_len) {
1284 case 6:
1285 /* 21-bit LBA and 8-bit sectors */
1286 cdb[1] = (lba >> 16) & 0x1f;
1287 cdb[2] = (lba >> 8) & 0xff;
1288 cdb[3] = lba & 0xff;
1289 cdb[4] = sectors & 0xff;
1290 break;
1291 case 10:
1292 /* 32-bit LBA and 16-bit sectors */
1293 put_unaligned_be32(lba, &cdb[2]);
1294 put_unaligned_be16(sectors, &cdb[7]);
1295 break;
1296 case 12:
1297 /* 32-bit LBA and 32-bit sectors */
1298 put_unaligned_be32(lba, &cdb[2]);
1299 put_unaligned_be32(sectors, &cdb[6]);
1300 break;
1301 case 16:
1302 /* 64-bit LBA and 32-bit sectors */
1303 put_unaligned_be64(lba, &cdb[2]);
1304 put_unaligned_be32(sectors, &cdb[10]);
1305 break;
1306 case 32:
1307 /* 64-bit LBA and 32-bit sectors, extended CDB */
1308 put_unaligned_be64(lba, &cdb[12]);
1309 put_unaligned_be32(sectors, &cdb[28]);
1310 break;
1311 default:
1312 BUG();
1313 }
1281 } 1314 }
1282} 1315}
1283EXPORT_SYMBOL(target_get_task_cdb); 1316EXPORT_SYMBOL(target_get_task_cdb);
diff --git a/drivers/target/target_core_scdb.c b/drivers/target/target_core_scdb.c
deleted file mode 100644
index 72843441d4fa..000000000000
--- a/drivers/target/target_core_scdb.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/*******************************************************************************
2 * Filename: target_core_scdb.c
3 *
4 * This file contains the generic target engine Split CDB related functions.
5 *
6 * Copyright (c) 2004-2005 PyX Technologies, Inc.
7 * Copyright (c) 2005, 2006, 2007 SBE, Inc.
8 * Copyright (c) 2007-2010 Rising Tide Systems
9 * Copyright (c) 2008-2010 Linux-iSCSI.org
10 *
11 * Nicholas A. Bellinger <nab@kernel.org>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 *
27 ******************************************************************************/
28
29#include <linux/net.h>
30#include <linux/string.h>
31#include <scsi/scsi.h>
32#include <asm/unaligned.h>
33
34#include <target/target_core_base.h>
35#include <target/target_core_transport.h>
36
37#include "target_core_scdb.h"
38
39/* split_cdb_XX_6():
40 *
41 * 21-bit LBA w/ 8-bit SECTORS
42 */
43void split_cdb_XX_6(
44 unsigned long long lba,
45 u32 sectors,
46 unsigned char *cdb)
47{
48 cdb[1] = (lba >> 16) & 0x1f;
49 cdb[2] = (lba >> 8) & 0xff;
50 cdb[3] = lba & 0xff;
51 cdb[4] = sectors & 0xff;
52}
53
54/* split_cdb_XX_10():
55 *
56 * 32-bit LBA w/ 16-bit SECTORS
57 */
58void split_cdb_XX_10(
59 unsigned long long lba,
60 u32 sectors,
61 unsigned char *cdb)
62{
63 put_unaligned_be32(lba, &cdb[2]);
64 put_unaligned_be16(sectors, &cdb[7]);
65}
66
67/* split_cdb_XX_12():
68 *
69 * 32-bit LBA w/ 32-bit SECTORS
70 */
71void split_cdb_XX_12(
72 unsigned long long lba,
73 u32 sectors,
74 unsigned char *cdb)
75{
76 put_unaligned_be32(lba, &cdb[2]);
77 put_unaligned_be32(sectors, &cdb[6]);
78}
79
80/* split_cdb_XX_16():
81 *
82 * 64-bit LBA w/ 32-bit SECTORS
83 */
84void split_cdb_XX_16(
85 unsigned long long lba,
86 u32 sectors,
87 unsigned char *cdb)
88{
89 put_unaligned_be64(lba, &cdb[2]);
90 put_unaligned_be32(sectors, &cdb[10]);
91}
92
93/*
94 * split_cdb_XX_32():
95 *
96 * 64-bit LBA w/ 32-bit SECTORS such as READ_32, WRITE_32 and emulated XDWRITEREAD_32
97 */
98void split_cdb_XX_32(
99 unsigned long long lba,
100 u32 sectors,
101 unsigned char *cdb)
102{
103 put_unaligned_be64(lba, &cdb[12]);
104 put_unaligned_be32(sectors, &cdb[28]);
105}
diff --git a/drivers/target/target_core_scdb.h b/drivers/target/target_core_scdb.h
deleted file mode 100644
index 48e9ccc9585e..000000000000
--- a/drivers/target/target_core_scdb.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef TARGET_CORE_SCDB_H
2#define TARGET_CORE_SCDB_H
3
4extern void split_cdb_XX_6(unsigned long long, u32, unsigned char *);
5extern void split_cdb_XX_10(unsigned long long, u32, unsigned char *);
6extern void split_cdb_XX_12(unsigned long long, u32, unsigned char *);
7extern void split_cdb_XX_16(unsigned long long, u32, unsigned char *);
8extern void split_cdb_XX_32(unsigned long long, u32, unsigned char *);
9
10#endif /* TARGET_CORE_SCDB_H */
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 3025a6f5ab56..cb022a1b22b3 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -54,7 +54,6 @@
54#include "target_core_alua.h" 54#include "target_core_alua.h"
55#include "target_core_hba.h" 55#include "target_core_hba.h"
56#include "target_core_pr.h" 56#include "target_core_pr.h"
57#include "target_core_scdb.h"
58#include "target_core_ua.h" 57#include "target_core_ua.h"
59 58
60static int sub_api_initialized; 59static int sub_api_initialized;
@@ -2851,7 +2850,6 @@ static int transport_generic_cmd_sequencer(
2851 if (sector_ret) 2850 if (sector_ret)
2852 goto out_unsupported_cdb; 2851 goto out_unsupported_cdb;
2853 size = transport_get_size(sectors, cdb, cmd); 2852 size = transport_get_size(sectors, cdb, cmd);
2854 cmd->transport_split_cdb = &split_cdb_XX_6;
2855 cmd->t_task_lba = transport_lba_21(cdb); 2853 cmd->t_task_lba = transport_lba_21(cdb);
2856 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2854 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2857 break; 2855 break;
@@ -2860,7 +2858,6 @@ static int transport_generic_cmd_sequencer(
2860 if (sector_ret) 2858 if (sector_ret)
2861 goto out_unsupported_cdb; 2859 goto out_unsupported_cdb;
2862 size = transport_get_size(sectors, cdb, cmd); 2860 size = transport_get_size(sectors, cdb, cmd);
2863 cmd->transport_split_cdb = &split_cdb_XX_10;
2864 cmd->t_task_lba = transport_lba_32(cdb); 2861 cmd->t_task_lba = transport_lba_32(cdb);
2865 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2862 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2866 break; 2863 break;
@@ -2869,7 +2866,6 @@ static int transport_generic_cmd_sequencer(
2869 if (sector_ret) 2866 if (sector_ret)
2870 goto out_unsupported_cdb; 2867 goto out_unsupported_cdb;
2871 size = transport_get_size(sectors, cdb, cmd); 2868 size = transport_get_size(sectors, cdb, cmd);
2872 cmd->transport_split_cdb = &split_cdb_XX_12;
2873 cmd->t_task_lba = transport_lba_32(cdb); 2869 cmd->t_task_lba = transport_lba_32(cdb);
2874 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2870 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2875 break; 2871 break;
@@ -2878,7 +2874,6 @@ static int transport_generic_cmd_sequencer(
2878 if (sector_ret) 2874 if (sector_ret)
2879 goto out_unsupported_cdb; 2875 goto out_unsupported_cdb;
2880 size = transport_get_size(sectors, cdb, cmd); 2876 size = transport_get_size(sectors, cdb, cmd);
2881 cmd->transport_split_cdb = &split_cdb_XX_16;
2882 cmd->t_task_lba = transport_lba_64(cdb); 2877 cmd->t_task_lba = transport_lba_64(cdb);
2883 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2878 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2884 break; 2879 break;
@@ -2887,7 +2882,6 @@ static int transport_generic_cmd_sequencer(
2887 if (sector_ret) 2882 if (sector_ret)
2888 goto out_unsupported_cdb; 2883 goto out_unsupported_cdb;
2889 size = transport_get_size(sectors, cdb, cmd); 2884 size = transport_get_size(sectors, cdb, cmd);
2890 cmd->transport_split_cdb = &split_cdb_XX_6;
2891 cmd->t_task_lba = transport_lba_21(cdb); 2885 cmd->t_task_lba = transport_lba_21(cdb);
2892 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2886 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2893 break; 2887 break;
@@ -2896,7 +2890,6 @@ static int transport_generic_cmd_sequencer(
2896 if (sector_ret) 2890 if (sector_ret)
2897 goto out_unsupported_cdb; 2891 goto out_unsupported_cdb;
2898 size = transport_get_size(sectors, cdb, cmd); 2892 size = transport_get_size(sectors, cdb, cmd);
2899 cmd->transport_split_cdb = &split_cdb_XX_10;
2900 cmd->t_task_lba = transport_lba_32(cdb); 2893 cmd->t_task_lba = transport_lba_32(cdb);
2901 cmd->t_tasks_fua = (cdb[1] & 0x8); 2894 cmd->t_tasks_fua = (cdb[1] & 0x8);
2902 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2895 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
@@ -2906,7 +2899,6 @@ static int transport_generic_cmd_sequencer(
2906 if (sector_ret) 2899 if (sector_ret)
2907 goto out_unsupported_cdb; 2900 goto out_unsupported_cdb;
2908 size = transport_get_size(sectors, cdb, cmd); 2901 size = transport_get_size(sectors, cdb, cmd);
2909 cmd->transport_split_cdb = &split_cdb_XX_12;
2910 cmd->t_task_lba = transport_lba_32(cdb); 2902 cmd->t_task_lba = transport_lba_32(cdb);
2911 cmd->t_tasks_fua = (cdb[1] & 0x8); 2903 cmd->t_tasks_fua = (cdb[1] & 0x8);
2912 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2904 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
@@ -2916,7 +2908,6 @@ static int transport_generic_cmd_sequencer(
2916 if (sector_ret) 2908 if (sector_ret)
2917 goto out_unsupported_cdb; 2909 goto out_unsupported_cdb;
2918 size = transport_get_size(sectors, cdb, cmd); 2910 size = transport_get_size(sectors, cdb, cmd);
2919 cmd->transport_split_cdb = &split_cdb_XX_16;
2920 cmd->t_task_lba = transport_lba_64(cdb); 2911 cmd->t_task_lba = transport_lba_64(cdb);
2921 cmd->t_tasks_fua = (cdb[1] & 0x8); 2912 cmd->t_tasks_fua = (cdb[1] & 0x8);
2922 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2913 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
@@ -2929,7 +2920,6 @@ static int transport_generic_cmd_sequencer(
2929 if (sector_ret) 2920 if (sector_ret)
2930 goto out_unsupported_cdb; 2921 goto out_unsupported_cdb;
2931 size = transport_get_size(sectors, cdb, cmd); 2922 size = transport_get_size(sectors, cdb, cmd);
2932 cmd->transport_split_cdb = &split_cdb_XX_10;
2933 cmd->t_task_lba = transport_lba_32(cdb); 2923 cmd->t_task_lba = transport_lba_32(cdb);
2934 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2924 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2935 passthrough = (dev->transport->transport_type == 2925 passthrough = (dev->transport->transport_type ==
@@ -2964,7 +2954,6 @@ static int transport_generic_cmd_sequencer(
2964 * Use WRITE_32 and READ_32 opcodes for the emulated 2954 * Use WRITE_32 and READ_32 opcodes for the emulated
2965 * XDWRITE_READ_32 logic. 2955 * XDWRITE_READ_32 logic.
2966 */ 2956 */
2967 cmd->transport_split_cdb = &split_cdb_XX_32;
2968 cmd->t_task_lba = transport_lba_64_ext(cdb); 2957 cmd->t_task_lba = transport_lba_64_ext(cdb);
2969 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; 2958 cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
2970 2959