target: Address legacy PYX_TRANSPORT_* return code breakage
[linux/fpc-iii.git] / include / target / target_core_transport.h
blobdac4f2d859fd72734fbc54ffda839216fe554079
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 TRANSPORT_PLUGIN_PHBA_PDEV 1
14 #define TRANSPORT_PLUGIN_VHBA_PDEV 2
15 #define TRANSPORT_PLUGIN_VHBA_VDEV 3
18 * struct se_subsystem_dev->su_dev_flags
20 #define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001
21 #define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002
22 #define SDF_USING_UDEV_PATH 0x00000004
23 #define SDF_USING_ALIAS 0x00000008
26 * struct se_device->dev_flags
28 #define DF_READ_ONLY 0x00000001
29 #define DF_SPC2_RESERVATIONS 0x00000002
30 #define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
32 /* struct se_dev_attrib sanity values */
33 /* Default max_unmap_lba_count */
34 #define DA_MAX_UNMAP_LBA_COUNT 0
35 /* Default max_unmap_block_desc_count */
36 #define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
37 /* Default unmap_granularity */
38 #define DA_UNMAP_GRANULARITY_DEFAULT 0
39 /* Default unmap_granularity_alignment */
40 #define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
41 /* Emulation for Direct Page Out */
42 #define DA_EMULATE_DPO 0
43 /* Emulation for Forced Unit Access WRITEs */
44 #define DA_EMULATE_FUA_WRITE 1
45 /* Emulation for Forced Unit Access READs */
46 #define DA_EMULATE_FUA_READ 0
47 /* Emulation for WriteCache and SYNCHRONIZE_CACHE */
48 #define DA_EMULATE_WRITE_CACHE 0
49 /* Emulation for UNIT ATTENTION Interlock Control */
50 #define DA_EMULATE_UA_INTLLCK_CTRL 0
51 /* Emulation for TASK_ABORTED status (TAS) by default */
52 #define DA_EMULATE_TAS 1
53 /* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
54 #define DA_EMULATE_TPU 0
56 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
57 * block/blk-lib.c:blkdev_issue_discard()
59 #define DA_EMULATE_TPWS 0
60 /* No Emulation for PSCSI by default */
61 #define DA_EMULATE_RESERVATIONS 0
62 /* No Emulation for PSCSI by default */
63 #define DA_EMULATE_ALUA 0
64 /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
65 #define DA_ENFORCE_PR_ISIDS 1
66 #define DA_STATUS_MAX_SECTORS_MIN 16
67 #define DA_STATUS_MAX_SECTORS_MAX 8192
68 /* By default don't report non-rotating (solid state) medium */
69 #define DA_IS_NONROT 0
70 /* Queue Algorithm Modifier default for restricted reordering in control mode page */
71 #define DA_EMULATE_REST_REORD 0
73 #define SE_MODE_PAGE_BUF 512
75 #define MOD_MAX_SECTORS(ms, bs) (ms % (PAGE_SIZE / bs))
77 struct se_subsystem_api;
79 extern int init_se_kmem_caches(void);
80 extern void release_se_kmem_caches(void);
81 extern u32 scsi_get_new_index(scsi_index_t);
82 extern void transport_init_queue_obj(struct se_queue_obj *);
83 extern void transport_subsystem_check_init(void);
84 extern int transport_subsystem_register(struct se_subsystem_api *);
85 extern void transport_subsystem_release(struct se_subsystem_api *);
86 extern void transport_load_plugins(void);
87 extern struct se_session *transport_init_session(void);
88 extern void __transport_register_session(struct se_portal_group *,
89 struct se_node_acl *,
90 struct se_session *, void *);
91 extern void transport_register_session(struct se_portal_group *,
92 struct se_node_acl *,
93 struct se_session *, void *);
94 extern void transport_free_session(struct se_session *);
95 extern void transport_deregister_session_configfs(struct se_session *);
96 extern void transport_deregister_session(struct se_session *);
97 extern void transport_cmd_finish_abort(struct se_cmd *, int);
98 extern void transport_complete_sync_cache(struct se_cmd *, int);
99 extern void transport_complete_task(struct se_task *, int);
100 extern void transport_add_task_to_execute_queue(struct se_task *,
101 struct se_task *,
102 struct se_device *);
103 extern void transport_remove_task_from_execute_queue(struct se_task *,
104 struct se_device *);
105 extern void __transport_remove_task_from_execute_queue(struct se_task *,
106 struct se_device *);
107 unsigned char *transport_dump_cmd_direction(struct se_cmd *);
108 extern void transport_dump_dev_state(struct se_device *, char *, int *);
109 extern void transport_dump_dev_info(struct se_device *, struct se_lun *,
110 unsigned long long, char *, int *);
111 extern void transport_dump_vpd_proto_id(struct t10_vpd *,
112 unsigned char *, int);
113 extern void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
114 extern int transport_dump_vpd_assoc(struct t10_vpd *,
115 unsigned char *, int);
116 extern int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
117 extern int transport_dump_vpd_ident_type(struct t10_vpd *,
118 unsigned char *, int);
119 extern int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
120 extern int transport_dump_vpd_ident(struct t10_vpd *,
121 unsigned char *, int);
122 extern int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
123 extern struct se_device *transport_add_device_to_core_hba(struct se_hba *,
124 struct se_subsystem_api *,
125 struct se_subsystem_dev *, u32,
126 void *, struct se_dev_limits *,
127 const char *, const char *);
128 extern void transport_init_se_cmd(struct se_cmd *,
129 struct target_core_fabric_ops *,
130 struct se_session *, u32, int, int,
131 unsigned char *);
132 void *transport_kmap_first_data_page(struct se_cmd *cmd);
133 void transport_kunmap_first_data_page(struct se_cmd *cmd);
134 extern int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
135 extern int transport_handle_cdb_direct(struct se_cmd *);
136 extern int transport_generic_handle_cdb_map(struct se_cmd *);
137 extern int transport_generic_handle_data(struct se_cmd *);
138 extern int transport_generic_handle_tmr(struct se_cmd *);
139 extern bool target_stop_task(struct se_task *task, unsigned long *flags);
140 extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32,
141 struct scatterlist *, u32);
142 extern int transport_clear_lun_from_sessions(struct se_lun *);
143 extern bool transport_wait_for_tasks(struct se_cmd *);
144 extern int transport_check_aborted_status(struct se_cmd *, int);
145 extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
146 extern void transport_send_task_abort(struct se_cmd *);
147 extern void transport_release_cmd(struct se_cmd *);
148 extern void transport_generic_free_cmd(struct se_cmd *, int);
149 extern void target_get_sess_cmd(struct se_session *, struct se_cmd *);
150 extern int target_put_sess_cmd(struct se_session *, struct se_cmd *);
151 extern void target_splice_sess_cmd_list(struct se_session *);
152 extern void target_wait_for_sess_cmds(struct se_session *, int);
153 extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
154 extern void transport_do_task_sg_chain(struct se_cmd *);
155 extern void transport_generic_process_write(struct se_cmd *);
156 extern int transport_generic_new_cmd(struct se_cmd *);
157 extern int transport_generic_do_tmr(struct se_cmd *);
158 /* From target_core_alua.c */
159 extern int core_alua_check_nonop_delay(struct se_cmd *);
160 /* From target_core_cdb.c */
161 extern int transport_emulate_control_cdb(struct se_task *);
162 extern void target_get_task_cdb(struct se_task *task, unsigned char *cdb);
165 * Each se_transport_task_t can have N number of possible struct se_task's
166 * for the storage transport(s) to possibly execute.
167 * Used primarily for splitting up CDBs that exceed the physical storage
168 * HBA's maximum sector count per task.
170 struct se_mem {
171 struct page *se_page;
172 u32 se_len;
173 u32 se_off;
174 struct list_head se_list;
175 } ____cacheline_aligned;
178 * Each type of disk transport supported MUST have a template defined
179 * within its .h file.
181 struct se_subsystem_api {
183 * The Name. :-)
185 char name[16];
187 * Transport Type.
189 u8 transport_type;
191 unsigned int fua_write_emulated : 1;
192 unsigned int write_cache_emulated : 1;
195 * struct module for struct se_hba references
197 struct module *owner;
199 * Used for global se_subsystem_api list_head
201 struct list_head sub_api_list;
203 * attach_hba():
205 int (*attach_hba)(struct se_hba *, u32);
207 * detach_hba():
209 void (*detach_hba)(struct se_hba *);
211 * pmode_hba(): Used for TCM/pSCSI subsystem plugin HBA ->
212 * Linux/SCSI struct Scsi_Host passthrough
214 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
216 * allocate_virtdevice():
218 void *(*allocate_virtdevice)(struct se_hba *, const char *);
220 * create_virtdevice(): Only for Virtual HBAs
222 struct se_device *(*create_virtdevice)(struct se_hba *,
223 struct se_subsystem_dev *, void *);
225 * free_device():
227 void (*free_device)(void *);
230 * transport_complete():
232 * Use transport_generic_complete() for majority of DAS transport
233 * drivers. Provided out of convenience.
235 int (*transport_complete)(struct se_task *task);
236 struct se_task *(*alloc_task)(unsigned char *cdb);
238 * do_task():
240 int (*do_task)(struct se_task *);
242 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
243 * UNMAP and WRITE_SAME_* w/ UNMAP=1 <-> Linux/Block Discard
245 int (*do_discard)(struct se_device *, sector_t, u32);
247 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
248 * SYNCHRONIZE_CACHE_* <-> Linux/Block blkdev_issue_flush()
250 void (*do_sync_cache)(struct se_task *);
252 * free_task():
254 void (*free_task)(struct se_task *);
256 * check_configfs_dev_params():
258 ssize_t (*check_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *);
260 * set_configfs_dev_params():
262 ssize_t (*set_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
263 const char *, ssize_t);
265 * show_configfs_dev_params():
267 ssize_t (*show_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
268 char *);
270 * get_device_rev():
272 u32 (*get_device_rev)(struct se_device *);
274 * get_device_type():
276 u32 (*get_device_type)(struct se_device *);
278 * Get the sector_t from a subsystem backstore..
280 sector_t (*get_blocks)(struct se_device *);
282 * get_sense_buffer():
284 unsigned char *(*get_sense_buffer)(struct se_task *);
285 } ____cacheline_aligned;
287 #endif /* TARGET_CORE_TRANSPORT_H */