1 #ifndef TARGET_CORE_TRANSPORT_H
2 #define TARGET_CORE_TRANSPORT_H
4 #define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION
6 /* Attempts before moving from SHORT to LONG */
7 #define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
8 #define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
9 #define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG 10 /* In milliseconds */
11 #define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */
13 #define PYX_TRANSPORT_SENT_TO_TRANSPORT 0
14 #define PYX_TRANSPORT_WRITE_PENDING 1
16 #define PYX_TRANSPORT_UNKNOWN_SAM_OPCODE -1
17 #define PYX_TRANSPORT_HBA_QUEUE_FULL -2
18 #define PYX_TRANSPORT_REQ_TOO_MANY_SECTORS -3
19 #define PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES -4
20 #define PYX_TRANSPORT_INVALID_CDB_FIELD -5
21 #define PYX_TRANSPORT_INVALID_PARAMETER_LIST -6
22 #define PYX_TRANSPORT_LU_COMM_FAILURE -7
23 #define PYX_TRANSPORT_UNKNOWN_MODE_PAGE -8
24 #define PYX_TRANSPORT_WRITE_PROTECTED -9
25 #define PYX_TRANSPORT_RESERVATION_CONFLICT -10
26 #define PYX_TRANSPORT_ILLEGAL_REQUEST -11
27 #define PYX_TRANSPORT_USE_SENSE_REASON -12
29 #ifndef SAM_STAT_RESERVATION_CONFLICT
30 #define SAM_STAT_RESERVATION_CONFLICT 0x18
33 #define TRANSPORT_PLUGIN_FREE 0
34 #define TRANSPORT_PLUGIN_REGISTERED 1
36 #define TRANSPORT_PLUGIN_PHBA_PDEV 1
37 #define TRANSPORT_PLUGIN_VHBA_PDEV 2
38 #define TRANSPORT_PLUGIN_VHBA_VDEV 3
41 * struct se_subsystem_dev->su_dev_flags
43 #define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001
44 #define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002
45 #define SDF_USING_UDEV_PATH 0x00000004
46 #define SDF_USING_ALIAS 0x00000008
49 * struct se_device->dev_flags
51 #define DF_READ_ONLY 0x00000001
52 #define DF_SPC2_RESERVATIONS 0x00000002
53 #define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
55 /* struct se_dev_attrib sanity values */
56 /* Default max_unmap_lba_count */
57 #define DA_MAX_UNMAP_LBA_COUNT 0
58 /* Default max_unmap_block_desc_count */
59 #define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
60 /* Default unmap_granularity */
61 #define DA_UNMAP_GRANULARITY_DEFAULT 0
62 /* Default unmap_granularity_alignment */
63 #define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
64 /* Emulation for Direct Page Out */
65 #define DA_EMULATE_DPO 0
66 /* Emulation for Forced Unit Access WRITEs */
67 #define DA_EMULATE_FUA_WRITE 1
68 /* Emulation for Forced Unit Access READs */
69 #define DA_EMULATE_FUA_READ 0
70 /* Emulation for WriteCache and SYNCHRONIZE_CACHE */
71 #define DA_EMULATE_WRITE_CACHE 0
72 /* Emulation for UNIT ATTENTION Interlock Control */
73 #define DA_EMULATE_UA_INTLLCK_CTRL 0
74 /* Emulation for TASK_ABORTED status (TAS) by default */
75 #define DA_EMULATE_TAS 1
76 /* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
77 #define DA_EMULATE_TPU 0
79 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
80 * block/blk-lib.c:blkdev_issue_discard()
82 #define DA_EMULATE_TPWS 0
83 /* No Emulation for PSCSI by default */
84 #define DA_EMULATE_RESERVATIONS 0
85 /* No Emulation for PSCSI by default */
86 #define DA_EMULATE_ALUA 0
87 /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
88 #define DA_ENFORCE_PR_ISIDS 1
89 #define DA_STATUS_MAX_SECTORS_MIN 16
90 #define DA_STATUS_MAX_SECTORS_MAX 8192
91 /* By default don't report non-rotating (solid state) medium */
92 #define DA_IS_NONROT 0
93 /* Queue Algorithm Modifier default for restricted reordering in control mode page */
94 #define DA_EMULATE_REST_REORD 0
96 #define SE_MODE_PAGE_BUF 512
98 #define MOD_MAX_SECTORS(ms, bs) (ms % (PAGE_SIZE / bs))
100 struct se_subsystem_api
;
102 extern int init_se_kmem_caches(void);
103 extern void release_se_kmem_caches(void);
104 extern u32
scsi_get_new_index(scsi_index_t
);
105 extern void transport_init_queue_obj(struct se_queue_obj
*);
106 extern void transport_subsystem_check_init(void);
107 extern int transport_subsystem_register(struct se_subsystem_api
*);
108 extern void transport_subsystem_release(struct se_subsystem_api
*);
109 extern void transport_load_plugins(void);
110 extern struct se_session
*transport_init_session(void);
111 extern void __transport_register_session(struct se_portal_group
*,
112 struct se_node_acl
*,
113 struct se_session
*, void *);
114 extern void transport_register_session(struct se_portal_group
*,
115 struct se_node_acl
*,
116 struct se_session
*, void *);
117 extern void transport_free_session(struct se_session
*);
118 extern void transport_deregister_session_configfs(struct se_session
*);
119 extern void transport_deregister_session(struct se_session
*);
120 extern void transport_cmd_finish_abort(struct se_cmd
*, int);
121 extern void transport_complete_sync_cache(struct se_cmd
*, int);
122 extern void transport_complete_task(struct se_task
*, int);
123 extern void transport_add_task_to_execute_queue(struct se_task
*,
126 extern void transport_remove_task_from_execute_queue(struct se_task
*,
128 extern void __transport_remove_task_from_execute_queue(struct se_task
*,
130 unsigned char *transport_dump_cmd_direction(struct se_cmd
*);
131 extern void transport_dump_dev_state(struct se_device
*, char *, int *);
132 extern void transport_dump_dev_info(struct se_device
*, struct se_lun
*,
133 unsigned long long, char *, int *);
134 extern void transport_dump_vpd_proto_id(struct t10_vpd
*,
135 unsigned char *, int);
136 extern void transport_set_vpd_proto_id(struct t10_vpd
*, unsigned char *);
137 extern int transport_dump_vpd_assoc(struct t10_vpd
*,
138 unsigned char *, int);
139 extern int transport_set_vpd_assoc(struct t10_vpd
*, unsigned char *);
140 extern int transport_dump_vpd_ident_type(struct t10_vpd
*,
141 unsigned char *, int);
142 extern int transport_set_vpd_ident_type(struct t10_vpd
*, unsigned char *);
143 extern int transport_dump_vpd_ident(struct t10_vpd
*,
144 unsigned char *, int);
145 extern int transport_set_vpd_ident(struct t10_vpd
*, unsigned char *);
146 extern struct se_device
*transport_add_device_to_core_hba(struct se_hba
*,
147 struct se_subsystem_api
*,
148 struct se_subsystem_dev
*, u32
,
149 void *, struct se_dev_limits
*,
150 const char *, const char *);
151 extern void transport_init_se_cmd(struct se_cmd
*,
152 struct target_core_fabric_ops
*,
153 struct se_session
*, u32
, int, int,
155 void *transport_kmap_first_data_page(struct se_cmd
*cmd
);
156 void transport_kunmap_first_data_page(struct se_cmd
*cmd
);
157 extern int transport_generic_allocate_tasks(struct se_cmd
*, unsigned char *);
158 extern int transport_handle_cdb_direct(struct se_cmd
*);
159 extern int transport_generic_handle_cdb_map(struct se_cmd
*);
160 extern int transport_generic_handle_data(struct se_cmd
*);
161 extern void transport_new_cmd_failure(struct se_cmd
*);
162 extern int transport_generic_handle_tmr(struct se_cmd
*);
163 extern bool target_stop_task(struct se_task
*task
, unsigned long *flags
);
164 extern int transport_generic_map_mem_to_cmd(struct se_cmd
*cmd
, struct scatterlist
*, u32
,
165 struct scatterlist
*, u32
);
166 extern int transport_clear_lun_from_sessions(struct se_lun
*);
167 extern bool transport_wait_for_tasks(struct se_cmd
*);
168 extern int transport_check_aborted_status(struct se_cmd
*, int);
169 extern int transport_send_check_condition_and_sense(struct se_cmd
*, u8
, int);
170 extern void transport_send_task_abort(struct se_cmd
*);
171 extern void transport_release_cmd(struct se_cmd
*);
172 extern void transport_generic_free_cmd(struct se_cmd
*, int);
173 extern void target_get_sess_cmd(struct se_session
*, struct se_cmd
*);
174 extern int target_put_sess_cmd(struct se_session
*, struct se_cmd
*);
175 extern void target_splice_sess_cmd_list(struct se_session
*);
176 extern void target_wait_for_sess_cmds(struct se_session
*, int);
177 extern void transport_generic_wait_for_cmds(struct se_cmd
*, int);
178 extern void transport_do_task_sg_chain(struct se_cmd
*);
179 extern void transport_generic_process_write(struct se_cmd
*);
180 extern int transport_generic_new_cmd(struct se_cmd
*);
181 extern int transport_generic_do_tmr(struct se_cmd
*);
182 /* From target_core_alua.c */
183 extern int core_alua_check_nonop_delay(struct se_cmd
*);
184 /* From target_core_cdb.c */
185 extern int transport_emulate_control_cdb(struct se_task
*);
186 extern void target_get_task_cdb(struct se_task
*task
, unsigned char *cdb
);
189 * Each se_transport_task_t can have N number of possible struct se_task's
190 * for the storage transport(s) to possibly execute.
191 * Used primarily for splitting up CDBs that exceed the physical storage
192 * HBA's maximum sector count per task.
195 struct page
*se_page
;
198 struct list_head se_list
;
199 } ____cacheline_aligned
;
202 * Each type of disk transport supported MUST have a template defined
203 * within its .h file.
205 struct se_subsystem_api
{
215 unsigned int fua_write_emulated
: 1;
216 unsigned int write_cache_emulated
: 1;
219 * struct module for struct se_hba references
221 struct module
*owner
;
223 * Used for global se_subsystem_api list_head
225 struct list_head sub_api_list
;
229 int (*attach_hba
)(struct se_hba
*, u32
);
233 void (*detach_hba
)(struct se_hba
*);
235 * pmode_hba(): Used for TCM/pSCSI subsystem plugin HBA ->
236 * Linux/SCSI struct Scsi_Host passthrough
238 int (*pmode_enable_hba
)(struct se_hba
*, unsigned long);
240 * allocate_virtdevice():
242 void *(*allocate_virtdevice
)(struct se_hba
*, const char *);
244 * create_virtdevice(): Only for Virtual HBAs
246 struct se_device
*(*create_virtdevice
)(struct se_hba
*,
247 struct se_subsystem_dev
*, void *);
251 void (*free_device
)(void *);
254 * transport_complete():
256 * Use transport_generic_complete() for majority of DAS transport
257 * drivers. Provided out of convenience.
259 int (*transport_complete
)(struct se_task
*task
);
260 struct se_task
*(*alloc_task
)(unsigned char *cdb
);
264 int (*do_task
)(struct se_task
*);
266 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
267 * UNMAP and WRITE_SAME_* w/ UNMAP=1 <-> Linux/Block Discard
269 int (*do_discard
)(struct se_device
*, sector_t
, u32
);
271 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
272 * SYNCHRONIZE_CACHE_* <-> Linux/Block blkdev_issue_flush()
274 void (*do_sync_cache
)(struct se_task
*);
278 void (*free_task
)(struct se_task
*);
280 * check_configfs_dev_params():
282 ssize_t (*check_configfs_dev_params
)(struct se_hba
*, struct se_subsystem_dev
*);
284 * set_configfs_dev_params():
286 ssize_t (*set_configfs_dev_params
)(struct se_hba
*, struct se_subsystem_dev
*,
287 const char *, ssize_t
);
289 * show_configfs_dev_params():
291 ssize_t (*show_configfs_dev_params
)(struct se_hba
*, struct se_subsystem_dev
*,
296 u32 (*get_device_rev
)(struct se_device
*);
300 u32 (*get_device_type
)(struct se_device
*);
302 * Get the sector_t from a subsystem backstore..
304 sector_t (*get_blocks
)(struct se_device
*);
306 * get_sense_buffer():
308 unsigned char *(*get_sense_buffer
)(struct se_task
*);
309 } ____cacheline_aligned
;
311 #endif /* TARGET_CORE_TRANSPORT_H */