aboutsummaryrefslogtreecommitdiffstats
path: root/include/target
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/target
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/target')
-rw-r--r--include/target/configfs_macros.h4
-rw-r--r--include/target/target_core_backend.h72
-rw-r--r--include/target/target_core_base.h571
-rw-r--r--include/target/target_core_fabric.h178
4 files changed, 336 insertions, 489 deletions
diff --git a/include/target/configfs_macros.h b/include/target/configfs_macros.h
index a0fc85bbe2d..7fe74608b43 100644
--- a/include/target/configfs_macros.h
+++ b/include/target/configfs_macros.h
@@ -30,8 +30,8 @@
30 * Added CONFIGFS_EATTR() macros from original configfs.h macros 30 * Added CONFIGFS_EATTR() macros from original configfs.h macros
31 * Copright (C) 2008-2009 Nicholas A. Bellinger <nab@linux-iscsi.org> 31 * Copright (C) 2008-2009 Nicholas A. Bellinger <nab@linux-iscsi.org>
32 * 32 *
33 * Please read Documentation/filesystems/configfs/configfs.txt before using 33 * Please read Documentation/filesystems/configfs.txt before using the
34 * the configfs interface, ESPECIALLY the parts about reference counts and 34 * configfs interface, ESPECIALLY the parts about reference counts and
35 * item destructors. 35 * item destructors.
36 */ 36 */
37 37
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
deleted file mode 100644
index 507910992c5..00000000000
--- a/include/target/target_core_backend.h
+++ /dev/null
@@ -1,72 +0,0 @@
1#ifndef TARGET_CORE_BACKEND_H
2#define TARGET_CORE_BACKEND_H
3
4#define TRANSPORT_PLUGIN_PHBA_PDEV 1
5#define TRANSPORT_PLUGIN_VHBA_PDEV 2
6#define TRANSPORT_PLUGIN_VHBA_VDEV 3
7
8struct se_subsystem_api {
9 struct list_head sub_api_list;
10
11 char name[16];
12 char inquiry_prod[16];
13 char inquiry_rev[4];
14 struct module *owner;
15
16 u8 transport_type;
17
18 int (*attach_hba)(struct se_hba *, u32);
19 void (*detach_hba)(struct se_hba *);
20 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
21
22 struct se_device *(*alloc_device)(struct se_hba *, const char *);
23 int (*configure_device)(struct se_device *);
24 void (*free_device)(struct se_device *device);
25
26 ssize_t (*set_configfs_dev_params)(struct se_device *,
27 const char *, ssize_t);
28 ssize_t (*show_configfs_dev_params)(struct se_device *, char *);
29
30 void (*transport_complete)(struct se_cmd *cmd,
31 struct scatterlist *,
32 unsigned char *);
33
34 sense_reason_t (*parse_cdb)(struct se_cmd *cmd);
35 u32 (*get_device_type)(struct se_device *);
36 sector_t (*get_blocks)(struct se_device *);
37 unsigned char *(*get_sense_buffer)(struct se_cmd *);
38};
39
40struct sbc_ops {
41 sense_reason_t (*execute_rw)(struct se_cmd *cmd);
42 sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd);
43 sense_reason_t (*execute_write_same)(struct se_cmd *cmd);
44 sense_reason_t (*execute_write_same_unmap)(struct se_cmd *cmd);
45 sense_reason_t (*execute_unmap)(struct se_cmd *cmd);
46};
47
48int transport_subsystem_register(struct se_subsystem_api *);
49void transport_subsystem_release(struct se_subsystem_api *);
50
51void target_complete_cmd(struct se_cmd *, u8);
52
53sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
54sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd);
55sector_t spc_get_write_same_sectors(struct se_cmd *cmd);
56
57sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops);
58u32 sbc_get_device_rev(struct se_device *dev);
59u32 sbc_get_device_type(struct se_device *dev);
60
61void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
62int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
63int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
64int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
65
66/* core helpers also used by command snooping in pscsi */
67void *transport_kmap_data_sg(struct se_cmd *);
68void transport_kunmap_data_sg(struct se_cmd *);
69
70void array_free(void *array, int n);
71
72#endif /* TARGET_CORE_BACKEND_H */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 7cae2360221..27040653005 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -9,9 +9,11 @@
9#include <net/sock.h> 9#include <net/sock.h>
10#include <net/tcp.h> 10#include <net/tcp.h>
11 11
12#define TARGET_CORE_MOD_VERSION "v4.1.0-rc2-ml" 12#define TARGET_CORE_MOD_VERSION "v4.1.0-rc1-ml"
13#define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION 13#define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))
14 14
15/* Used by transport_generic_allocate_iovecs() */
16#define TRANSPORT_IOV_DATA_BUFFER 5
15/* Maximum Number of LUNs per Target Portal Group */ 17/* Maximum Number of LUNs per Target Portal Group */
16/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */ 18/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */
17#define TRANSPORT_MAX_LUNS_PER_TPG 256 19#define TRANSPORT_MAX_LUNS_PER_TPG 256
@@ -35,7 +37,6 @@
35#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE 37#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE
36/* Used by transport_send_check_condition_and_sense() */ 38/* Used by transport_send_check_condition_and_sense() */
37#define SPC_SENSE_KEY_OFFSET 2 39#define SPC_SENSE_KEY_OFFSET 2
38#define SPC_ADD_SENSE_LEN_OFFSET 7
39#define SPC_ASC_KEY_OFFSET 12 40#define SPC_ASC_KEY_OFFSET 12
40#define SPC_ASCQ_KEY_OFFSET 13 41#define SPC_ASCQ_KEY_OFFSET 13
41#define TRANSPORT_IQN_LEN 224 42#define TRANSPORT_IQN_LEN 224
@@ -55,60 +56,6 @@
55/* Used by transport_get_inquiry_vpd_device_ident() */ 56/* Used by transport_get_inquiry_vpd_device_ident() */
56#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254 57#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254
57 58
58/* Attempts before moving from SHORT to LONG */
59#define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
60#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
61#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG 10 /* In milliseconds */
62
63#define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */
64
65/* struct se_dev_attrib sanity values */
66/* Default max_unmap_lba_count */
67#define DA_MAX_UNMAP_LBA_COUNT 0
68/* Default max_unmap_block_desc_count */
69#define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
70/* Default unmap_granularity */
71#define DA_UNMAP_GRANULARITY_DEFAULT 0
72/* Default unmap_granularity_alignment */
73#define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
74/* Default max_write_same_len, disabled by default */
75#define DA_MAX_WRITE_SAME_LEN 0
76/* Default max transfer length */
77#define DA_FABRIC_MAX_SECTORS 8192
78/* Emulation for Direct Page Out */
79#define DA_EMULATE_DPO 0
80/* Emulation for Forced Unit Access WRITEs */
81#define DA_EMULATE_FUA_WRITE 1
82/* Emulation for Forced Unit Access READs */
83#define DA_EMULATE_FUA_READ 0
84/* Emulation for WriteCache and SYNCHRONIZE_CACHE */
85#define DA_EMULATE_WRITE_CACHE 0
86/* Emulation for UNIT ATTENTION Interlock Control */
87#define DA_EMULATE_UA_INTLLCK_CTRL 0
88/* Emulation for TASK_ABORTED status (TAS) by default */
89#define DA_EMULATE_TAS 1
90/* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
91#define DA_EMULATE_TPU 0
92/*
93 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
94 * block/blk-lib.c:blkdev_issue_discard()
95 */
96#define DA_EMULATE_TPWS 0
97/* No Emulation for PSCSI by default */
98#define DA_EMULATE_ALUA 0
99/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
100#define DA_ENFORCE_PR_ISIDS 1
101#define DA_STATUS_MAX_SECTORS_MIN 16
102#define DA_STATUS_MAX_SECTORS_MAX 8192
103/* By default don't report non-rotating (solid state) medium */
104#define DA_IS_NONROT 0
105/* Queue Algorithm Modifier default for restricted reordering in control mode page */
106#define DA_EMULATE_REST_REORD 0
107
108#define SE_INQUIRY_BUF 512
109#define SE_MODE_PAGE_BUF 512
110#define SE_SENSE_BUF 96
111
112/* struct se_hba->hba_flags */ 59/* struct se_hba->hba_flags */
113enum hba_flags_table { 60enum hba_flags_table {
114 HBA_FLAGS_INTERNAL_USE = 0x01, 61 HBA_FLAGS_INTERNAL_USE = 0x01,
@@ -127,16 +74,33 @@ enum transport_tpg_type_table {
127 TRANSPORT_TPG_TYPE_DISCOVERY = 1, 74 TRANSPORT_TPG_TYPE_DISCOVERY = 1,
128}; 75};
129 76
77/* Used for generate timer flags */
78enum timer_flags_table {
79 TF_RUNNING = 0x01,
80 TF_STOP = 0x02,
81};
82
130/* Special transport agnostic struct se_cmd->t_states */ 83/* Special transport agnostic struct se_cmd->t_states */
131enum transport_state_table { 84enum transport_state_table {
132 TRANSPORT_NO_STATE = 0, 85 TRANSPORT_NO_STATE = 0,
133 TRANSPORT_NEW_CMD = 1, 86 TRANSPORT_NEW_CMD = 1,
87 TRANSPORT_DEFERRED_CMD = 2,
134 TRANSPORT_WRITE_PENDING = 3, 88 TRANSPORT_WRITE_PENDING = 3,
89 TRANSPORT_PROCESS_WRITE = 4,
135 TRANSPORT_PROCESSING = 5, 90 TRANSPORT_PROCESSING = 5,
136 TRANSPORT_COMPLETE = 6, 91 TRANSPORT_COMPLETE_OK = 6,
92 TRANSPORT_COMPLETE_FAILURE = 7,
93 TRANSPORT_COMPLETE_TIMEOUT = 8,
94 TRANSPORT_PROCESS_TMR = 9,
95 TRANSPORT_TMR_COMPLETE = 10,
137 TRANSPORT_ISTATE_PROCESSING = 11, 96 TRANSPORT_ISTATE_PROCESSING = 11,
97 TRANSPORT_ISTATE_PROCESSED = 12,
98 TRANSPORT_KILL = 13,
99 TRANSPORT_REMOVE = 14,
100 TRANSPORT_FREE = 15,
101 TRANSPORT_NEW_CMD_MAP = 16,
102 TRANSPORT_FREE_CMD_INTR = 17,
138 TRANSPORT_COMPLETE_QF_WP = 18, 103 TRANSPORT_COMPLETE_QF_WP = 18,
139 TRANSPORT_COMPLETE_QF_OK = 19,
140}; 104};
141 105
142/* Used for struct se_cmd->se_cmd_flags */ 106/* Used for struct se_cmd->se_cmd_flags */
@@ -144,18 +108,24 @@ enum se_cmd_flags_table {
144 SCF_SUPPORTED_SAM_OPCODE = 0x00000001, 108 SCF_SUPPORTED_SAM_OPCODE = 0x00000001,
145 SCF_TRANSPORT_TASK_SENSE = 0x00000002, 109 SCF_TRANSPORT_TASK_SENSE = 0x00000002,
146 SCF_EMULATED_TASK_SENSE = 0x00000004, 110 SCF_EMULATED_TASK_SENSE = 0x00000004,
147 SCF_SCSI_DATA_CDB = 0x00000008, 111 SCF_SCSI_DATA_SG_IO_CDB = 0x00000008,
148 SCF_SCSI_TMR_CDB = 0x00000010, 112 SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010,
149 SCF_FUA = 0x00000080, 113 SCF_SCSI_NON_DATA_CDB = 0x00000040,
150 SCF_SE_LUN_CMD = 0x00000100, 114 SCF_SCSI_CDB_EXCEPTION = 0x00000080,
151 SCF_BIDI = 0x00000400, 115 SCF_SCSI_RESERVATION_CONFLICT = 0x00000100,
152 SCF_SENT_CHECK_CONDITION = 0x00000800, 116 SCF_SE_CMD_FAILED = 0x00000400,
153 SCF_OVERFLOW_BIT = 0x00001000, 117 SCF_SE_LUN_CMD = 0x00000800,
154 SCF_UNDERFLOW_BIT = 0x00002000, 118 SCF_SE_ALLOW_EOO = 0x00001000,
155 SCF_SENT_DELAYED_TAS = 0x00004000, 119 SCF_SENT_CHECK_CONDITION = 0x00004000,
156 SCF_ALUA_NON_OPTIMIZED = 0x00008000, 120 SCF_OVERFLOW_BIT = 0x00008000,
157 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000, 121 SCF_UNDERFLOW_BIT = 0x00010000,
158 SCF_ACK_KREF = 0x00040000, 122 SCF_SENT_DELAYED_TAS = 0x00020000,
123 SCF_ALUA_NON_OPTIMIZED = 0x00040000,
124 SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
125 SCF_UNUSED = 0x00100000,
126 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
127 SCF_EMULATE_CDB_ASYNC = 0x01000000,
128 SCF_EMULATE_QUEUE_FULL = 0x02000000,
159}; 129};
160 130
161/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ 131/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
@@ -166,64 +136,61 @@ enum transport_lunflags_table {
166 TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, 136 TRANSPORT_LUNFLAGS_READ_WRITE = 0x04,
167}; 137};
168 138
139/* struct se_device->dev_status */
140enum transport_device_status_table {
141 TRANSPORT_DEVICE_ACTIVATED = 0x01,
142 TRANSPORT_DEVICE_DEACTIVATED = 0x02,
143 TRANSPORT_DEVICE_QUEUE_FULL = 0x04,
144 TRANSPORT_DEVICE_SHUTDOWN = 0x08,
145 TRANSPORT_DEVICE_OFFLINE_ACTIVATED = 0x10,
146 TRANSPORT_DEVICE_OFFLINE_DEACTIVATED = 0x20,
147};
148
169/* 149/*
170 * Used by transport_send_check_condition_and_sense() 150 * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason
171 * to signal which ASC/ASCQ sense payload should be built. 151 * to signal which ASC/ASCQ sense payload should be built.
172 */ 152 */
173typedef unsigned __bitwise__ sense_reason_t;
174
175enum tcm_sense_reason_table { 153enum tcm_sense_reason_table {
176#define R(x) (__force sense_reason_t )(x) 154 TCM_NON_EXISTENT_LUN = 0x01,
177 TCM_NON_EXISTENT_LUN = R(0x01), 155 TCM_UNSUPPORTED_SCSI_OPCODE = 0x02,
178 TCM_UNSUPPORTED_SCSI_OPCODE = R(0x02), 156 TCM_INCORRECT_AMOUNT_OF_DATA = 0x03,
179 TCM_INCORRECT_AMOUNT_OF_DATA = R(0x03), 157 TCM_UNEXPECTED_UNSOLICITED_DATA = 0x04,
180 TCM_UNEXPECTED_UNSOLICITED_DATA = R(0x04), 158 TCM_SERVICE_CRC_ERROR = 0x05,
181 TCM_SERVICE_CRC_ERROR = R(0x05), 159 TCM_SNACK_REJECTED = 0x06,
182 TCM_SNACK_REJECTED = R(0x06), 160 TCM_SECTOR_COUNT_TOO_MANY = 0x07,
183 TCM_SECTOR_COUNT_TOO_MANY = R(0x07), 161 TCM_INVALID_CDB_FIELD = 0x08,
184 TCM_INVALID_CDB_FIELD = R(0x08), 162 TCM_INVALID_PARAMETER_LIST = 0x09,
185 TCM_INVALID_PARAMETER_LIST = R(0x09), 163 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = 0x0a,
186 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = R(0x0a), 164 TCM_UNKNOWN_MODE_PAGE = 0x0b,
187 TCM_UNKNOWN_MODE_PAGE = R(0x0b), 165 TCM_WRITE_PROTECTED = 0x0c,
188 TCM_WRITE_PROTECTED = R(0x0c), 166 TCM_CHECK_CONDITION_ABORT_CMD = 0x0d,
189 TCM_CHECK_CONDITION_ABORT_CMD = R(0x0d), 167 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e,
190 TCM_CHECK_CONDITION_UNIT_ATTENTION = R(0x0e), 168 TCM_CHECK_CONDITION_NOT_READY = 0x0f,
191 TCM_CHECK_CONDITION_NOT_READY = R(0x0f), 169};
192 TCM_RESERVATION_CONFLICT = R(0x10), 170
193 TCM_ADDRESS_OUT_OF_RANGE = R(0x11), 171struct se_obj {
194 TCM_OUT_OF_RESOURCES = R(0x12), 172 atomic_t obj_access_count;
195#undef R 173} ____cacheline_aligned;
196};
197 174
198enum target_sc_flags_table { 175/*
199 TARGET_SCF_BIDI_OP = 0x01, 176 * Used by TCM Core internally to signal if ALUA emulation is enabled or
200 TARGET_SCF_ACK_KREF = 0x02, 177 * disabled, or running in with TCM/pSCSI passthrough mode
201 TARGET_SCF_UNKNOWN_SIZE = 0x04, 178 */
202}; 179typedef enum {
203 180 SPC_ALUA_PASSTHROUGH,
204/* fabric independent task management function values */ 181 SPC2_ALUA_DISABLED,
205enum tcm_tmreq_table { 182 SPC3_ALUA_EMULATED
206 TMR_ABORT_TASK = 1, 183} t10_alua_index_t;
207 TMR_ABORT_TASK_SET = 2,
208 TMR_CLEAR_ACA = 3,
209 TMR_CLEAR_TASK_SET = 4,
210 TMR_LUN_RESET = 5,
211 TMR_TARGET_WARM_RESET = 6,
212 TMR_TARGET_COLD_RESET = 7,
213 TMR_FABRIC_TMR = 255,
214};
215 184
216/* fabric independent task management response values */ 185/*
217enum tcm_tmrsp_table { 186 * Used by TCM Core internally to signal if SAM Task Attribute emulation
218 TMR_FUNCTION_COMPLETE = 0, 187 * is enabled or disabled, or running in with TCM/pSCSI passthrough mode
219 TMR_TASK_DOES_NOT_EXIST = 1, 188 */
220 TMR_LUN_DOES_NOT_EXIST = 2, 189typedef enum {
221 TMR_TASK_STILL_ALLEGIANT = 3, 190 SAM_TASK_ATTR_PASSTHROUGH,
222 TMR_TASK_FAILOVER_NOT_SUPPORTED = 4, 191 SAM_TASK_ATTR_UNTAGGED,
223 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 5, 192 SAM_TASK_ATTR_EMULATED
224 TMR_FUNCTION_AUTHORIZATION_FAILED = 6, 193} t10_task_attr_index_t;
225 TMR_FUNCTION_REJECTED = 255,
226};
227 194
228/* 195/*
229 * Used for target SCSI statistics 196 * Used for target SCSI statistics
@@ -238,28 +205,31 @@ typedef enum {
238struct se_cmd; 205struct se_cmd;
239 206
240struct t10_alua { 207struct t10_alua {
208 t10_alua_index_t alua_type;
241 /* ALUA Target Port Group ID */ 209 /* ALUA Target Port Group ID */
242 u16 alua_tg_pt_gps_counter; 210 u16 alua_tg_pt_gps_counter;
243 u32 alua_tg_pt_gps_count; 211 u32 alua_tg_pt_gps_count;
244 spinlock_t tg_pt_gps_lock; 212 spinlock_t tg_pt_gps_lock;
245 struct se_device *t10_dev; 213 struct se_subsystem_dev *t10_sub_dev;
246 /* Used for default ALUA Target Port Group */ 214 /* Used for default ALUA Target Port Group */
247 struct t10_alua_tg_pt_gp *default_tg_pt_gp; 215 struct t10_alua_tg_pt_gp *default_tg_pt_gp;
248 /* Used for default ALUA Target Port Group ConfigFS group */ 216 /* Used for default ALUA Target Port Group ConfigFS group */
249 struct config_group alua_tg_pt_gps_group; 217 struct config_group alua_tg_pt_gps_group;
218 int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *);
250 struct list_head tg_pt_gps_list; 219 struct list_head tg_pt_gps_list;
251}; 220} ____cacheline_aligned;
252 221
253struct t10_alua_lu_gp { 222struct t10_alua_lu_gp {
254 u16 lu_gp_id; 223 u16 lu_gp_id;
255 int lu_gp_valid_id; 224 int lu_gp_valid_id;
256 u32 lu_gp_members; 225 u32 lu_gp_members;
226 atomic_t lu_gp_shutdown;
257 atomic_t lu_gp_ref_cnt; 227 atomic_t lu_gp_ref_cnt;
258 spinlock_t lu_gp_lock; 228 spinlock_t lu_gp_lock;
259 struct config_group lu_gp_group; 229 struct config_group lu_gp_group;
260 struct list_head lu_gp_node; 230 struct list_head lu_gp_node;
261 struct list_head lu_gp_mem_list; 231 struct list_head lu_gp_mem_list;
262}; 232} ____cacheline_aligned;
263 233
264struct t10_alua_lu_gp_member { 234struct t10_alua_lu_gp_member {
265 bool lu_gp_assoc; 235 bool lu_gp_assoc;
@@ -268,7 +238,7 @@ struct t10_alua_lu_gp_member {
268 struct t10_alua_lu_gp *lu_gp; 238 struct t10_alua_lu_gp *lu_gp;
269 struct se_device *lu_gp_mem_dev; 239 struct se_device *lu_gp_mem_dev;
270 struct list_head lu_gp_mem_list; 240 struct list_head lu_gp_mem_list;
271}; 241} ____cacheline_aligned;
272 242
273struct t10_alua_tg_pt_gp { 243struct t10_alua_tg_pt_gp {
274 u16 tg_pt_gp_id; 244 u16 tg_pt_gp_id;
@@ -277,7 +247,6 @@ struct t10_alua_tg_pt_gp {
277 int tg_pt_gp_alua_access_type; 247 int tg_pt_gp_alua_access_type;
278 int tg_pt_gp_nonop_delay_msecs; 248 int tg_pt_gp_nonop_delay_msecs;
279 int tg_pt_gp_trans_delay_msecs; 249 int tg_pt_gp_trans_delay_msecs;
280 int tg_pt_gp_implict_trans_secs;
281 int tg_pt_gp_pref; 250 int tg_pt_gp_pref;
282 int tg_pt_gp_write_metadata; 251 int tg_pt_gp_write_metadata;
283 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */ 252 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */
@@ -288,11 +257,11 @@ struct t10_alua_tg_pt_gp {
288 atomic_t tg_pt_gp_ref_cnt; 257 atomic_t tg_pt_gp_ref_cnt;
289 spinlock_t tg_pt_gp_lock; 258 spinlock_t tg_pt_gp_lock;
290 struct mutex tg_pt_gp_md_mutex; 259 struct mutex tg_pt_gp_md_mutex;
291 struct se_device *tg_pt_gp_dev; 260 struct se_subsystem_dev *tg_pt_gp_su_dev;
292 struct config_group tg_pt_gp_group; 261 struct config_group tg_pt_gp_group;
293 struct list_head tg_pt_gp_list; 262 struct list_head tg_pt_gp_list;
294 struct list_head tg_pt_gp_mem_list; 263 struct list_head tg_pt_gp_mem_list;
295}; 264} ____cacheline_aligned;
296 265
297struct t10_alua_tg_pt_gp_member { 266struct t10_alua_tg_pt_gp_member {
298 bool tg_pt_gp_assoc; 267 bool tg_pt_gp_assoc;
@@ -301,7 +270,7 @@ struct t10_alua_tg_pt_gp_member {
301 struct t10_alua_tg_pt_gp *tg_pt_gp; 270 struct t10_alua_tg_pt_gp *tg_pt_gp;
302 struct se_port *tg_pt; 271 struct se_port *tg_pt;
303 struct list_head tg_pt_gp_mem_list; 272 struct list_head tg_pt_gp_mem_list;
304}; 273} ____cacheline_aligned;
305 274
306struct t10_vpd { 275struct t10_vpd {
307 unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN]; 276 unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN];
@@ -311,7 +280,7 @@ struct t10_vpd {
311 u32 association; 280 u32 association;
312 u32 device_identifier_type; 281 u32 device_identifier_type;
313 struct list_head vpd_list; 282 struct list_head vpd_list;
314}; 283} ____cacheline_aligned;
315 284
316struct t10_wwn { 285struct t10_wwn {
317 char vendor[8]; 286 char vendor[8];
@@ -319,10 +288,22 @@ struct t10_wwn {
319 char revision[4]; 288 char revision[4];
320 char unit_serial[INQUIRY_VPD_SERIAL_LEN]; 289 char unit_serial[INQUIRY_VPD_SERIAL_LEN];
321 spinlock_t t10_vpd_lock; 290 spinlock_t t10_vpd_lock;
322 struct se_device *t10_dev; 291 struct se_subsystem_dev *t10_sub_dev;
323 struct config_group t10_wwn_group; 292 struct config_group t10_wwn_group;
324 struct list_head t10_vpd_list; 293 struct list_head t10_vpd_list;
325}; 294} ____cacheline_aligned;
295
296
297/*
298 * Used by TCM Core internally to signal if >= SPC-3 persistent reservations
299 * emulation is enabled or disabled, or running in with TCM/pSCSI passthrough
300 * mode
301 */
302typedef enum {
303 SPC_PASSTHROUGH,
304 SPC2_RESERVATIONS,
305 SPC3_PERSISTENT_RESERVATIONS
306} t10_reservations_index_t;
326 307
327struct t10_pr_registration { 308struct t10_pr_registration {
328 /* Used for fabrics that contain WWN+ISID */ 309 /* Used for fabrics that contain WWN+ISID */
@@ -363,6 +344,18 @@ struct t10_pr_registration {
363 struct list_head pr_reg_aptpl_list; 344 struct list_head pr_reg_aptpl_list;
364 struct list_head pr_reg_atp_list; 345 struct list_head pr_reg_atp_list;
365 struct list_head pr_reg_atp_mem_list; 346 struct list_head pr_reg_atp_mem_list;
347} ____cacheline_aligned;
348
349/*
350 * This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS,
351 * SPC2_RESERVATIONS or SPC_PASSTHROUGH in drivers/target/target_core_pr.c:
352 * core_setup_reservations()
353 */
354struct t10_reservation_ops {
355 int (*t10_reservation_check)(struct se_cmd *, u32 *);
356 int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32);
357 int (*t10_pr_register)(struct se_cmd *);
358 int (*t10_pr_clear)(struct se_cmd *);
366}; 359};
367 360
368struct t10_reservation { 361struct t10_reservation {
@@ -375,6 +368,7 @@ struct t10_reservation {
375#define PR_APTPL_BUF_LEN 8192 368#define PR_APTPL_BUF_LEN 8192
376 u32 pr_aptpl_buf_len; 369 u32 pr_aptpl_buf_len;
377 u32 pr_generation; 370 u32 pr_generation;
371 t10_reservations_index_t res_type;
378 spinlock_t registration_lock; 372 spinlock_t registration_lock;
379 spinlock_t aptpl_reg_lock; 373 spinlock_t aptpl_reg_lock;
380 /* 374 /*
@@ -390,28 +384,59 @@ struct t10_reservation {
390 struct se_node_acl *pr_res_holder; 384 struct se_node_acl *pr_res_holder;
391 struct list_head registration_list; 385 struct list_head registration_list;
392 struct list_head aptpl_reg_list; 386 struct list_head aptpl_reg_list;
393}; 387 struct t10_reservation_ops pr_ops;
394 388} ____cacheline_aligned;
395struct se_tmr_req { 389
396 /* Task Management function to be performed */ 390struct se_queue_req {
397 u8 function; 391 int state;
398 /* Task Management response to send */ 392 struct se_cmd *cmd;
399 u8 response; 393 struct list_head qr_list;
400 int call_transport; 394} ____cacheline_aligned;
401 /* Reference to ITT that Task Mgmt should be performed */ 395
402 u32 ref_task_tag; 396struct se_queue_obj {
403 void *fabric_tmr_ptr; 397 atomic_t queue_cnt;
404 struct se_cmd *task_cmd; 398 spinlock_t cmd_queue_lock;
405 struct se_device *tmr_dev; 399 struct list_head qobj_list;
406 struct se_lun *tmr_lun; 400 wait_queue_head_t thread_wq;
407 struct list_head tmr_list; 401} ____cacheline_aligned;
408}; 402
403struct se_task {
404 unsigned char task_sense;
405 struct scatterlist *task_sg;
406 u32 task_sg_nents;
407 struct scatterlist *task_sg_bidi;
408 u8 task_scsi_status;
409 u8 task_flags;
410 int task_error_status;
411 int task_state_flags;
412 bool task_padded_sg;
413 unsigned long long task_lba;
414 u32 task_no;
415 u32 task_sectors;
416 u32 task_size;
417 enum dma_data_direction task_data_direction;
418 struct se_cmd *task_se_cmd;
419 struct se_device *se_dev;
420 struct completion task_stop_comp;
421 atomic_t task_active;
422 atomic_t task_execute_queue;
423 atomic_t task_timeout;
424 atomic_t task_sent;
425 atomic_t task_stop;
426 atomic_t task_state_active;
427 struct timer_list task_timer;
428 struct se_device *se_obj_ptr;
429 struct list_head t_list;
430 struct list_head t_execute_list;
431 struct list_head t_state_list;
432} ____cacheline_aligned;
409 433
410struct se_cmd { 434struct se_cmd {
411 /* SAM response code being sent to initiator */ 435 /* SAM response code being sent to initiator */
412 u8 scsi_status; 436 u8 scsi_status;
413 u8 scsi_asc; 437 u8 scsi_asc;
414 u8 scsi_ascq; 438 u8 scsi_ascq;
439 u8 scsi_sense_reason;
415 u16 scsi_sense_length; 440 u16 scsi_sense_length;
416 /* Delay for ALUA Active/NonOptimized state access in milliseconds */ 441 /* Delay for ALUA Active/NonOptimized state access in milliseconds */
417 int alua_nonop_delay; 442 int alua_nonop_delay;
@@ -421,76 +446,110 @@ struct se_cmd {
421 int sam_task_attr; 446 int sam_task_attr;
422 /* Transport protocol dependent state, see transport_state_table */ 447 /* Transport protocol dependent state, see transport_state_table */
423 enum transport_state_table t_state; 448 enum transport_state_table t_state;
424 /* Used to signal cmd->se_tfo->check_release_cmd() usage per cmd */ 449 /* Transport protocol dependent state for out of order CmdSNs */
425 unsigned check_release:1; 450 int deferred_t_state;
426 unsigned cmd_wait_set:1; 451 /* Transport specific error status */
427 unsigned unknown_data_length:1; 452 int transport_error_status;
428 /* See se_cmd_flags_table */ 453 /* See se_cmd_flags_table */
429 u32 se_cmd_flags; 454 u32 se_cmd_flags;
430 u32 se_ordered_id; 455 u32 se_ordered_id;
431 /* Total size in bytes associated with command */ 456 /* Total size in bytes associated with command */
432 u32 data_length; 457 u32 data_length;
458 /* SCSI Presented Data Transfer Length */
459 u32 cmd_spdtl;
433 u32 residual_count; 460 u32 residual_count;
434 u32 orig_fe_lun; 461 u32 orig_fe_lun;
435 /* Persistent Reservation key */ 462 /* Persistent Reservation key */
436 u64 pr_res_key; 463 u64 pr_res_key;
464 atomic_t transport_sent;
437 /* Used for sense data */ 465 /* Used for sense data */
438 void *sense_buffer; 466 void *sense_buffer;
439 struct list_head se_delayed_node; 467 struct list_head se_delayed_node;
468 struct list_head se_ordered_node;
440 struct list_head se_lun_node; 469 struct list_head se_lun_node;
441 struct list_head se_qf_node; 470 struct list_head se_qf_node;
442 struct se_device *se_dev; 471 struct se_device *se_dev;
443 struct se_dev_entry *se_deve; 472 struct se_dev_entry *se_deve;
473 struct se_device *se_obj_ptr;
474 struct se_device *se_orig_obj_ptr;
444 struct se_lun *se_lun; 475 struct se_lun *se_lun;
445 /* Only used for internal passthrough and legacy TCM fabric modules */ 476 /* Only used for internal passthrough and legacy TCM fabric modules */
446 struct se_session *se_sess; 477 struct se_session *se_sess;
447 struct se_tmr_req *se_tmr_req; 478 struct se_tmr_req *se_tmr_req;
448 struct list_head se_cmd_list; 479 struct list_head se_queue_node;
449 struct completion cmd_wait_comp;
450 struct kref cmd_kref;
451 struct target_core_fabric_ops *se_tfo; 480 struct target_core_fabric_ops *se_tfo;
452 sense_reason_t (*execute_cmd)(struct se_cmd *); 481 int (*transport_emulate_cdb)(struct se_cmd *);
482 void (*transport_split_cdb)(unsigned long long, u32, unsigned char *);
483 void (*transport_wait_for_tasks)(struct se_cmd *, int, int);
453 void (*transport_complete_callback)(struct se_cmd *); 484 void (*transport_complete_callback)(struct se_cmd *);
485 int (*transport_qf_callback)(struct se_cmd *);
454 486
455 unsigned char *t_task_cdb; 487 unsigned char *t_task_cdb;
456 unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE]; 488 unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
457 unsigned long long t_task_lba; 489 unsigned long long t_task_lba;
490 int t_tasks_failed;
491 int t_tasks_fua;
492 bool t_tasks_bidi;
493 u32 t_tasks_sg_chained_no;
458 atomic_t t_fe_count; 494 atomic_t t_fe_count;
459 unsigned int transport_state; 495 atomic_t t_se_count;
460#define CMD_T_ABORTED (1 << 0) 496 atomic_t t_task_cdbs_left;
461#define CMD_T_ACTIVE (1 << 1) 497 atomic_t t_task_cdbs_ex_left;
462#define CMD_T_COMPLETE (1 << 2) 498 atomic_t t_task_cdbs_timeout_left;
463#define CMD_T_QUEUED (1 << 3) 499 atomic_t t_task_cdbs_sent;
464#define CMD_T_SENT (1 << 4) 500 atomic_t t_transport_aborted;
465#define CMD_T_STOP (1 << 5) 501 atomic_t t_transport_active;
466#define CMD_T_FAILED (1 << 6) 502 atomic_t t_transport_complete;
467#define CMD_T_LUN_STOP (1 << 7) 503 atomic_t t_transport_queue_active;
468#define CMD_T_LUN_FE_STOP (1 << 8) 504 atomic_t t_transport_sent;
469#define CMD_T_DEV_ACTIVE (1 << 9) 505 atomic_t t_transport_stop;
470#define CMD_T_REQUEST_STOP (1 << 10) 506 atomic_t t_transport_timeout;
471#define CMD_T_BUSY (1 << 11) 507 atomic_t transport_dev_active;
508 atomic_t transport_lun_active;
509 atomic_t transport_lun_fe_stop;
510 atomic_t transport_lun_stop;
472 spinlock_t t_state_lock; 511 spinlock_t t_state_lock;
473 struct completion t_transport_stop_comp; 512 struct completion t_transport_stop_comp;
474 struct completion transport_lun_fe_stop_comp; 513 struct completion transport_lun_fe_stop_comp;
475 struct completion transport_lun_stop_comp; 514 struct completion transport_lun_stop_comp;
515 struct scatterlist *t_tasks_sg_chained;
476 516
477 struct work_struct work; 517 /*
518 * Used for pre-registered fabric SGL passthrough WRITE and READ
519 * with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop
520 * and other HW target mode fabric modules.
521 */
522 struct scatterlist *t_task_pt_sgl;
523 u32 t_task_pt_sgl_num;
478 524
479 struct scatterlist *t_data_sg; 525 struct scatterlist *t_data_sg;
480 unsigned int t_data_nents; 526 unsigned int t_data_nents;
481 void *t_data_vmap;
482 struct scatterlist *t_bidi_data_sg; 527 struct scatterlist *t_bidi_data_sg;
483 unsigned int t_bidi_data_nents; 528 unsigned int t_bidi_data_nents;
484 529
485 struct list_head state_list; 530 /* Used for BIDI READ */
486 bool state_active; 531 struct list_head t_task_list;
532 u32 t_task_list_num;
487 533
488 /* old task stop completion, consider merging with some of the above */ 534} ____cacheline_aligned;
489 struct completion task_stop_comp;
490 535
491 /* backend private data */ 536struct se_tmr_req {
492 void *priv; 537 /* Task Management function to be preformed */
493}; 538 u8 function;
539 /* Task Management response to send */
540 u8 response;
541 int call_transport;
542 /* Reference to ITT that Task Mgmt should be preformed */
543 u32 ref_task_tag;
544 /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
545 u64 ref_task_lun;
546 void *fabric_tmr_ptr;
547 struct se_cmd *task_cmd;
548 struct se_cmd *ref_cmd;
549 struct se_device *tmr_dev;
550 struct se_lun *tmr_lun;
551 struct list_head tmr_list;
552} ____cacheline_aligned;
494 553
495struct se_ua { 554struct se_ua {
496 u8 ua_asc; 555 u8 ua_asc;
@@ -498,24 +557,21 @@ struct se_ua {
498 struct se_node_acl *ua_nacl; 557 struct se_node_acl *ua_nacl;
499 struct list_head ua_dev_list; 558 struct list_head ua_dev_list;
500 struct list_head ua_nacl_list; 559 struct list_head ua_nacl_list;
501}; 560} ____cacheline_aligned;
502 561
503struct se_node_acl { 562struct se_node_acl {
504 char initiatorname[TRANSPORT_IQN_LEN]; 563 char initiatorname[TRANSPORT_IQN_LEN];
505 /* Used to signal demo mode created ACL, disabled by default */ 564 /* Used to signal demo mode created ACL, disabled by default */
506 bool dynamic_node_acl; 565 bool dynamic_node_acl;
507 bool acl_stop:1;
508 u32 queue_depth; 566 u32 queue_depth;
509 u32 acl_index; 567 u32 acl_index;
510#define MAX_ACL_TAG_SIZE 64
511 char acl_tag[MAX_ACL_TAG_SIZE];
512 u64 num_cmds; 568 u64 num_cmds;
513 u64 read_bytes; 569 u64 read_bytes;
514 u64 write_bytes; 570 u64 write_bytes;
515 spinlock_t stats_lock; 571 spinlock_t stats_lock;
516 /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ 572 /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
517 atomic_t acl_pr_ref_count; 573 atomic_t acl_pr_ref_count;
518 struct se_dev_entry **device_list; 574 struct se_dev_entry *device_list;
519 struct se_session *nacl_sess; 575 struct se_session *nacl_sess;
520 struct se_portal_group *se_tpg; 576 struct se_portal_group *se_tpg;
521 spinlock_t device_list_lock; 577 spinlock_t device_list_lock;
@@ -528,22 +584,16 @@ struct se_node_acl {
528 struct config_group *acl_default_groups[5]; 584 struct config_group *acl_default_groups[5];
529 struct list_head acl_list; 585 struct list_head acl_list;
530 struct list_head acl_sess_list; 586 struct list_head acl_sess_list;
531 struct completion acl_free_comp; 587} ____cacheline_aligned;
532 struct kref acl_kref;
533};
534 588
535struct se_session { 589struct se_session {
536 unsigned sess_tearing_down:1;
537 u64 sess_bin_isid; 590 u64 sess_bin_isid;
538 struct se_node_acl *se_node_acl; 591 struct se_node_acl *se_node_acl;
539 struct se_portal_group *se_tpg; 592 struct se_portal_group *se_tpg;
540 void *fabric_sess_ptr; 593 void *fabric_sess_ptr;
541 struct list_head sess_list; 594 struct list_head sess_list;
542 struct list_head sess_acl_list; 595 struct list_head sess_acl_list;
543 struct list_head sess_cmd_list; 596} ____cacheline_aligned;
544 spinlock_t sess_cmd_lock;
545 struct kref sess_kref;
546};
547 597
548struct se_device; 598struct se_device;
549struct se_transform_info; 599struct se_transform_info;
@@ -563,7 +613,7 @@ struct se_lun_acl {
563 struct list_head lacl_list; 613 struct list_head lacl_list;
564 struct config_group se_lun_group; 614 struct config_group se_lun_group;
565 struct se_ml_stat_grps ml_stat_grps; 615 struct se_ml_stat_grps ml_stat_grps;
566}; 616} ____cacheline_aligned;
567 617
568struct se_dev_entry { 618struct se_dev_entry {
569 bool def_pr_registered; 619 bool def_pr_registered;
@@ -588,7 +638,16 @@ struct se_dev_entry {
588 struct se_lun *se_lun; 638 struct se_lun *se_lun;
589 struct list_head alua_port_list; 639 struct list_head alua_port_list;
590 struct list_head ua_list; 640 struct list_head ua_list;
591}; 641} ____cacheline_aligned;
642
643struct se_dev_limits {
644 /* Max supported HW queue depth */
645 u32 hw_queue_depth;
646 /* Max supported virtual queue depth */
647 u32 queue_depth;
648 /* From include/linux/blkdev.h for the other HW/SW limits. */
649 struct queue_limits limits;
650} ____cacheline_aligned;
592 651
593struct se_dev_attrib { 652struct se_dev_attrib {
594 int emulate_dpo; 653 int emulate_dpo;
@@ -599,24 +658,26 @@ struct se_dev_attrib {
599 int emulate_tas; 658 int emulate_tas;
600 int emulate_tpu; 659 int emulate_tpu;
601 int emulate_tpws; 660 int emulate_tpws;
661 int emulate_reservations;
662 int emulate_alua;
602 int enforce_pr_isids; 663 int enforce_pr_isids;
603 int is_nonrot; 664 int is_nonrot;
604 int emulate_rest_reord; 665 int emulate_rest_reord;
605 u32 hw_block_size; 666 u32 hw_block_size;
606 u32 block_size; 667 u32 block_size;
607 u32 hw_max_sectors; 668 u32 hw_max_sectors;
608 u32 fabric_max_sectors; 669 u32 max_sectors;
609 u32 optimal_sectors; 670 u32 optimal_sectors;
610 u32 hw_queue_depth; 671 u32 hw_queue_depth;
611 u32 queue_depth; 672 u32 queue_depth;
673 u32 task_timeout;
612 u32 max_unmap_lba_count; 674 u32 max_unmap_lba_count;
613 u32 max_unmap_block_desc_count; 675 u32 max_unmap_block_desc_count;
614 u32 unmap_granularity; 676 u32 unmap_granularity;
615 u32 unmap_granularity_alignment; 677 u32 unmap_granularity_alignment;
616 u32 max_write_same_len; 678 struct se_subsystem_dev *da_sub_dev;
617 struct se_device *da_dev;
618 struct config_group da_group; 679 struct config_group da_group;
619}; 680} ____cacheline_aligned;
620 681
621struct se_dev_stat_grps { 682struct se_dev_stat_grps {
622 struct config_group stat_group; 683 struct config_group stat_group;
@@ -625,25 +686,53 @@ struct se_dev_stat_grps {
625 struct config_group scsi_lu_group; 686 struct config_group scsi_lu_group;
626}; 687};
627 688
689struct se_subsystem_dev {
690/* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */
691#define SE_DEV_ALIAS_LEN 512
692 unsigned char se_dev_alias[SE_DEV_ALIAS_LEN];
693/* Used for struct se_subsystem_dev->se_dev_udev_path[], must be less than PAGE_SIZE */
694#define SE_UDEV_PATH_LEN 512
695 unsigned char se_dev_udev_path[SE_UDEV_PATH_LEN];
696 u32 su_dev_flags;
697 struct se_hba *se_dev_hba;
698 struct se_device *se_dev_ptr;
699 struct se_dev_attrib se_dev_attrib;
700 /* T10 Asymmetric Logical Unit Assignment for Target Ports */
701 struct t10_alua t10_alua;
702 /* T10 Inquiry and VPD WWN Information */
703 struct t10_wwn t10_wwn;
704 /* T10 SPC-2 + SPC-3 Reservations */
705 struct t10_reservation t10_pr;
706 spinlock_t se_dev_lock;
707 void *se_dev_su_ptr;
708 struct list_head se_dev_node;
709 struct config_group se_dev_group;
710 /* For T10 Reservations */
711 struct config_group se_dev_pr_group;
712 /* For target_core_stat.c groups */
713 struct se_dev_stat_grps dev_stat_grps;
714} ____cacheline_aligned;
715
628struct se_device { 716struct se_device {
629#define SE_DEV_LINK_MAGIC 0xfeeddeef 717 /* Set to 1 if thread is NOT sleeping on thread_sem */
630 u32 dev_link_magic; 718 u8 thread_active;
719 u8 dev_status_timer_flags;
631 /* RELATIVE TARGET PORT IDENTIFER Counter */ 720 /* RELATIVE TARGET PORT IDENTIFER Counter */
632 u16 dev_rpti_counter; 721 u16 dev_rpti_counter;
633 /* Used for SAM Task Attribute ordering */ 722 /* Used for SAM Task Attribute ordering */
634 u32 dev_cur_ordered_id; 723 u32 dev_cur_ordered_id;
635 u32 dev_flags; 724 u32 dev_flags;
636#define DF_CONFIGURED 0x00000001
637#define DF_FIRMWARE_VPD_UNIT_SERIAL 0x00000002
638#define DF_EMULATED_VPD_UNIT_SERIAL 0x00000004
639#define DF_USING_UDEV_PATH 0x00000008
640#define DF_USING_ALIAS 0x00000010
641 u32 dev_port_count; 725 u32 dev_port_count;
726 /* See transport_device_status_table */
727 u32 dev_status;
728 u32 dev_tcq_window_closed;
642 /* Physical device queue depth */ 729 /* Physical device queue depth */
643 u32 queue_depth; 730 u32 queue_depth;
644 /* Used for SPC-2 reservations enforce of ISIDs */ 731 /* Used for SPC-2 reservations enforce of ISIDs */
645 u64 dev_res_bin_isid; 732 u64 dev_res_bin_isid;
733 t10_task_attr_index_t dev_task_attr_type;
646 /* Pointer to transport specific device structure */ 734 /* Pointer to transport specific device structure */
735 void *dev_ptr;
647 u32 dev_index; 736 u32 dev_index;
648 u64 creation_time; 737 u64 creation_time;
649 u32 num_resets; 738 u32 num_resets;
@@ -652,17 +741,29 @@ struct se_device {
652 u64 write_bytes; 741 u64 write_bytes;
653 spinlock_t stats_lock; 742 spinlock_t stats_lock;
654 /* Active commands on this virtual SE device */ 743 /* Active commands on this virtual SE device */
744 atomic_t active_cmds;
655 atomic_t simple_cmds; 745 atomic_t simple_cmds;
746 atomic_t depth_left;
656 atomic_t dev_ordered_id; 747 atomic_t dev_ordered_id;
748 atomic_t dev_tur_active;
749 atomic_t execute_tasks;
750 atomic_t dev_status_thr_count;
751 atomic_t dev_hoq_count;
657 atomic_t dev_ordered_sync; 752 atomic_t dev_ordered_sync;
658 atomic_t dev_qf_count; 753 atomic_t dev_qf_count;
659 int export_count; 754 struct se_obj dev_obj;
755 struct se_obj dev_access_obj;
756 struct se_obj dev_export_obj;
757 struct se_queue_obj dev_queue_obj;
660 spinlock_t delayed_cmd_lock; 758 spinlock_t delayed_cmd_lock;
759 spinlock_t ordered_cmd_lock;
661 spinlock_t execute_task_lock; 760 spinlock_t execute_task_lock;
761 spinlock_t state_task_lock;
762 spinlock_t dev_alua_lock;
662 spinlock_t dev_reservation_lock; 763 spinlock_t dev_reservation_lock;
663 unsigned int dev_reservation_flags; 764 spinlock_t dev_state_lock;
664#define DRF_SPC2_RESERVATIONS 0x00000001 765 spinlock_t dev_status_lock;
665#define DRF_SPC2_RESERVATIONS_WITH_ISID 0x00000002 766 spinlock_t dev_status_thr_lock;
666 spinlock_t se_port_lock; 767 spinlock_t se_port_lock;
667 spinlock_t se_tmr_lock; 768 spinlock_t se_tmr_lock;
668 spinlock_t qf_cmd_lock; 769 spinlock_t qf_cmd_lock;
@@ -674,32 +775,27 @@ struct se_device {
674 struct t10_pr_registration *dev_pr_res_holder; 775 struct t10_pr_registration *dev_pr_res_holder;
675 struct list_head dev_sep_list; 776 struct list_head dev_sep_list;
676 struct list_head dev_tmr_list; 777 struct list_head dev_tmr_list;
677 struct workqueue_struct *tmr_wq; 778 struct timer_list dev_status_timer;
779 /* Pointer to descriptor for processing thread */
780 struct task_struct *process_thread;
781 pid_t process_thread_pid;
782 struct task_struct *dev_mgmt_thread;
678 struct work_struct qf_work_queue; 783 struct work_struct qf_work_queue;
679 struct list_head delayed_cmd_list; 784 struct list_head delayed_cmd_list;
680 struct list_head state_list; 785 struct list_head ordered_cmd_list;
786 struct list_head execute_task_list;
787 struct list_head state_task_list;
681 struct list_head qf_cmd_list; 788 struct list_head qf_cmd_list;
682 /* Pointer to associated SE HBA */ 789 /* Pointer to associated SE HBA */
683 struct se_hba *se_hba; 790 struct se_hba *se_hba;
684 /* T10 Inquiry and VPD WWN Information */ 791 struct se_subsystem_dev *se_sub_dev;
685 struct t10_wwn t10_wwn;
686 /* T10 Asymmetric Logical Unit Assignment for Target Ports */
687 struct t10_alua t10_alua;
688 /* T10 SPC-2 + SPC-3 Reservations */
689 struct t10_reservation t10_pr;
690 struct se_dev_attrib dev_attrib;
691 struct config_group dev_group;
692 struct config_group dev_pr_group;
693 struct se_dev_stat_grps dev_stat_grps;
694#define SE_DEV_ALIAS_LEN 512 /* must be less than PAGE_SIZE */
695 unsigned char dev_alias[SE_DEV_ALIAS_LEN];
696#define SE_UDEV_PATH_LEN 512 /* must be less than PAGE_SIZE */
697 unsigned char udev_path[SE_UDEV_PATH_LEN];
698 /* Pointer to template of function pointers for transport */ 792 /* Pointer to template of function pointers for transport */
699 struct se_subsystem_api *transport; 793 struct se_subsystem_api *transport;
700 /* Linked list for struct se_hba struct se_device list */ 794 /* Linked list for struct se_hba struct se_device list */
701 struct list_head dev_list; 795 struct list_head dev_list;
702}; 796 /* Linked list for struct se_global->g_se_dev_list */
797 struct list_head g_se_dev_list;
798} ____cacheline_aligned;
703 799
704struct se_hba { 800struct se_hba {
705 u16 hba_tpgt; 801 u16 hba_tpgt;
@@ -711,12 +807,14 @@ struct se_hba {
711 u32 hba_index; 807 u32 hba_index;
712 /* Pointer to transport specific host structure. */ 808 /* Pointer to transport specific host structure. */
713 void *hba_ptr; 809 void *hba_ptr;
810 /* Linked list for struct se_device */
811 struct list_head hba_dev_list;
714 struct list_head hba_node; 812 struct list_head hba_node;
715 spinlock_t device_lock; 813 spinlock_t device_lock;
716 struct config_group hba_group; 814 struct config_group hba_group;
717 struct mutex hba_access_mutex; 815 struct mutex hba_access_mutex;
718 struct se_subsystem_api *transport; 816 struct se_subsystem_api *transport;
719}; 817} ____cacheline_aligned;
720 818
721struct se_port_stat_grps { 819struct se_port_stat_grps {
722 struct config_group stat_group; 820 struct config_group stat_group;
@@ -726,8 +824,6 @@ struct se_port_stat_grps {
726}; 824};
727 825
728struct se_lun { 826struct se_lun {
729#define SE_LUN_LINK_MAGIC 0xffff7771
730 u32 lun_link_magic;
731 /* See transport_lun_status_table */ 827 /* See transport_lun_status_table */
732 enum transport_lun_status_table lun_status; 828 enum transport_lun_status_table lun_status;
733 u32 lun_access; 829 u32 lun_access;
@@ -744,13 +840,13 @@ struct se_lun {
744 struct se_port *lun_sep; 840 struct se_port *lun_sep;
745 struct config_group lun_group; 841 struct config_group lun_group;
746 struct se_port_stat_grps port_stat_grps; 842 struct se_port_stat_grps port_stat_grps;
747}; 843} ____cacheline_aligned;
748 844
749struct scsi_port_stats { 845struct scsi_port_stats {
750 u64 cmd_pdus; 846 u64 cmd_pdus;
751 u64 tx_data_octets; 847 u64 tx_data_octets;
752 u64 rx_data_octets; 848 u64 rx_data_octets;
753}; 849} ____cacheline_aligned;
754 850
755struct se_port { 851struct se_port {
756 /* RELATIVE TARGET PORT IDENTIFER */ 852 /* RELATIVE TARGET PORT IDENTIFER */
@@ -760,6 +856,7 @@ struct se_port {
760 u32 sep_index; 856 u32 sep_index;
761 struct scsi_port_stats sep_stats; 857 struct scsi_port_stats sep_stats;
762 /* Used for ALUA Target Port Groups membership */ 858 /* Used for ALUA Target Port Groups membership */
859 atomic_t sep_tg_pt_gp_active;
763 atomic_t sep_tg_pt_secondary_offline; 860 atomic_t sep_tg_pt_secondary_offline;
764 /* Used for PR ALL_TG_PT=1 */ 861 /* Used for PR ALL_TG_PT=1 */
765 atomic_t sep_tg_pt_ref_cnt; 862 atomic_t sep_tg_pt_ref_cnt;
@@ -770,12 +867,12 @@ struct se_port {
770 struct se_portal_group *sep_tpg; 867 struct se_portal_group *sep_tpg;
771 struct list_head sep_alua_list; 868 struct list_head sep_alua_list;
772 struct list_head sep_list; 869 struct list_head sep_list;
773}; 870} ____cacheline_aligned;
774 871
775struct se_tpg_np { 872struct se_tpg_np {
776 struct se_portal_group *tpg_np_parent; 873 struct se_portal_group *tpg_np_parent;
777 struct config_group tpg_np_group; 874 struct config_group tpg_np_group;
778}; 875} ____cacheline_aligned;
779 876
780struct se_portal_group { 877struct se_portal_group {
781 /* Type of target portal group, see transport_tpg_type_table */ 878 /* Type of target portal group, see transport_tpg_type_table */
@@ -794,7 +891,7 @@ struct se_portal_group {
794 struct list_head se_tpg_node; 891 struct list_head se_tpg_node;
795 /* linked list for initiator ACL list */ 892 /* linked list for initiator ACL list */
796 struct list_head acl_node_list; 893 struct list_head acl_node_list;
797 struct se_lun **tpg_lun_list; 894 struct se_lun *tpg_lun_list;
798 struct se_lun tpg_virt_lun0; 895 struct se_lun tpg_virt_lun0;
799 /* List of TCM sessions associated wth this TPG */ 896 /* List of TCM sessions associated wth this TPG */
800 struct list_head tpg_sess_list; 897 struct list_head tpg_sess_list;
@@ -808,13 +905,13 @@ struct se_portal_group {
808 struct config_group tpg_acl_group; 905 struct config_group tpg_acl_group;
809 struct config_group tpg_attrib_group; 906 struct config_group tpg_attrib_group;
810 struct config_group tpg_param_group; 907 struct config_group tpg_param_group;
811}; 908} ____cacheline_aligned;
812 909
813struct se_wwn { 910struct se_wwn {
814 struct target_fabric_configfs *wwn_tf; 911 struct target_fabric_configfs *wwn_tf;
815 struct config_group wwn_group; 912 struct config_group wwn_group;
816 struct config_group *wwn_default_groups[2]; 913 struct config_group *wwn_default_groups[2];
817 struct config_group fabric_stat_group; 914 struct config_group fabric_stat_group;
818}; 915} ____cacheline_aligned;
819 916
820#endif /* TARGET_CORE_BASE_H */ 917#endif /* TARGET_CORE_BASE_H */
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
deleted file mode 100644
index aaa1ee6ab39..00000000000
--- a/include/target/target_core_fabric.h
+++ /dev/null
@@ -1,178 +0,0 @@
1#ifndef TARGET_CORE_FABRIC_H
2#define TARGET_CORE_FABRIC_H
3
4struct target_core_fabric_ops {
5 struct configfs_subsystem *tf_subsys;
6 char *(*get_fabric_name)(void);
7 u8 (*get_fabric_proto_ident)(struct se_portal_group *);
8 char *(*tpg_get_wwn)(struct se_portal_group *);
9 u16 (*tpg_get_tag)(struct se_portal_group *);
10 u32 (*tpg_get_default_depth)(struct se_portal_group *);
11 u32 (*tpg_get_pr_transport_id)(struct se_portal_group *,
12 struct se_node_acl *,
13 struct t10_pr_registration *, int *,
14 unsigned char *);
15 u32 (*tpg_get_pr_transport_id_len)(struct se_portal_group *,
16 struct se_node_acl *,
17 struct t10_pr_registration *, int *);
18 char *(*tpg_parse_pr_out_transport_id)(struct se_portal_group *,
19 const char *, u32 *, char **);
20 int (*tpg_check_demo_mode)(struct se_portal_group *);
21 int (*tpg_check_demo_mode_cache)(struct se_portal_group *);
22 int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);
23 int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);
24 /*
25 * Optionally used by fabrics to allow demo-mode login, but not
26 * expose any TPG LUNs, and return 'not connected' in standard
27 * inquiry response
28 */
29 int (*tpg_check_demo_mode_login_only)(struct se_portal_group *);
30 struct se_node_acl *(*tpg_alloc_fabric_acl)(
31 struct se_portal_group *);
32 void (*tpg_release_fabric_acl)(struct se_portal_group *,
33 struct se_node_acl *);
34 u32 (*tpg_get_inst_index)(struct se_portal_group *);
35 /*
36 * Optional to release struct se_cmd and fabric dependent allocated
37 * I/O descriptor in transport_cmd_check_stop().
38 *
39 * Returning 1 will signal a descriptor has been released.
40 * Returning 0 will signal a descriptor has not been released.
41 */
42 int (*check_stop_free)(struct se_cmd *);
43 void (*release_cmd)(struct se_cmd *);
44 void (*put_session)(struct se_session *);
45 /*
46 * Called with spin_lock_bh(struct se_portal_group->session_lock held.
47 */
48 int (*shutdown_session)(struct se_session *);
49 void (*close_session)(struct se_session *);
50 u32 (*sess_get_index)(struct se_session *);
51 /*
52 * Used only for SCSI fabrics that contain multi-value TransportIDs
53 * (like iSCSI). All other SCSI fabrics should set this to NULL.
54 */
55 u32 (*sess_get_initiator_sid)(struct se_session *,
56 unsigned char *, u32);
57 int (*write_pending)(struct se_cmd *);
58 int (*write_pending_status)(struct se_cmd *);
59 void (*set_default_node_attributes)(struct se_node_acl *);
60 u32 (*get_task_tag)(struct se_cmd *);
61 int (*get_cmd_state)(struct se_cmd *);
62 int (*queue_data_in)(struct se_cmd *);
63 int (*queue_status)(struct se_cmd *);
64 int (*queue_tm_rsp)(struct se_cmd *);
65 /*
66 * fabric module calls for target_core_fabric_configfs.c
67 */
68 struct se_wwn *(*fabric_make_wwn)(struct target_fabric_configfs *,
69 struct config_group *, const char *);
70 void (*fabric_drop_wwn)(struct se_wwn *);
71 struct se_portal_group *(*fabric_make_tpg)(struct se_wwn *,
72 struct config_group *, const char *);
73 void (*fabric_drop_tpg)(struct se_portal_group *);
74 int (*fabric_post_link)(struct se_portal_group *,
75 struct se_lun *);
76 void (*fabric_pre_unlink)(struct se_portal_group *,
77 struct se_lun *);
78 struct se_tpg_np *(*fabric_make_np)(struct se_portal_group *,
79 struct config_group *, const char *);
80 void (*fabric_drop_np)(struct se_tpg_np *);
81 struct se_node_acl *(*fabric_make_nodeacl)(struct se_portal_group *,
82 struct config_group *, const char *);
83 void (*fabric_drop_nodeacl)(struct se_node_acl *);
84};
85
86struct se_session *transport_init_session(void);
87void __transport_register_session(struct se_portal_group *,
88 struct se_node_acl *, struct se_session *, void *);
89void transport_register_session(struct se_portal_group *,
90 struct se_node_acl *, struct se_session *, void *);
91void target_get_session(struct se_session *);
92void target_put_session(struct se_session *);
93void transport_free_session(struct se_session *);
94void target_put_nacl(struct se_node_acl *);
95void transport_deregister_session_configfs(struct se_session *);
96void transport_deregister_session(struct se_session *);
97
98
99void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *,
100 struct se_session *, u32, int, int, unsigned char *);
101sense_reason_t transport_lookup_cmd_lun(struct se_cmd *, u32);
102sense_reason_t target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *);
103int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *,
104 unsigned char *, unsigned char *, u32, u32, int, int, int,
105 struct scatterlist *, u32, struct scatterlist *, u32);
106int target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *,
107 unsigned char *, u32, u32, int, int, int);
108int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
109 unsigned char *sense, u32 unpacked_lun,
110 void *fabric_tmr_ptr, unsigned char tm_type,
111 gfp_t, unsigned int, int);
112int transport_handle_cdb_direct(struct se_cmd *);
113sense_reason_t transport_generic_new_cmd(struct se_cmd *);
114
115void target_execute_cmd(struct se_cmd *cmd);
116
117void transport_generic_free_cmd(struct se_cmd *, int);
118
119bool transport_wait_for_tasks(struct se_cmd *);
120int transport_check_aborted_status(struct se_cmd *, int);
121int transport_send_check_condition_and_sense(struct se_cmd *,
122 sense_reason_t, int);
123
124int target_put_sess_cmd(struct se_session *, struct se_cmd *);
125void target_sess_cmd_list_set_waiting(struct se_session *);
126void target_wait_for_sess_cmds(struct se_session *, int);
127
128int core_alua_check_nonop_delay(struct se_cmd *);
129
130int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t);
131void core_tmr_release_req(struct se_tmr_req *);
132int transport_generic_handle_tmr(struct se_cmd *);
133void transport_generic_request_failure(struct se_cmd *, sense_reason_t);
134int transport_lookup_tmr_lun(struct se_cmd *, u32);
135
136struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *,
137 unsigned char *);
138void core_tpg_clear_object_luns(struct se_portal_group *);
139struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *,
140 struct se_node_acl *, const char *, u32);
141int core_tpg_del_initiator_node_acl(struct se_portal_group *,
142 struct se_node_acl *, int);
143int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
144 unsigned char *, u32, int);
145int core_tpg_set_initiator_node_tag(struct se_portal_group *,
146 struct se_node_acl *, const char *);
147int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *,
148 struct se_portal_group *, void *, int);
149int core_tpg_deregister(struct se_portal_group *);
150
151/* SAS helpers */
152u8 sas_get_fabric_proto_ident(struct se_portal_group *);
153u32 sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
154 struct t10_pr_registration *, int *, unsigned char *);
155u32 sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
156 struct t10_pr_registration *, int *);
157char *sas_parse_pr_out_transport_id(struct se_portal_group *, const char *,
158 u32 *, char **);
159
160/* FC helpers */
161u8 fc_get_fabric_proto_ident(struct se_portal_group *);
162u32 fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
163 struct t10_pr_registration *, int *, unsigned char *);
164u32 fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
165 struct t10_pr_registration *, int *);
166char *fc_parse_pr_out_transport_id(struct se_portal_group *, const char *,
167 u32 *, char **);
168
169/* iSCSI helpers */
170u8 iscsi_get_fabric_proto_ident(struct se_portal_group *);
171u32 iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
172 struct t10_pr_registration *, int *, unsigned char *);
173u32 iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
174 struct t10_pr_registration *, int *);
175char *iscsi_parse_pr_out_transport_id(struct se_portal_group *, const char *,
176 u32 *, char **);
177
178#endif /* TARGET_CORE_FABRICH */