diff options
Diffstat (limited to 'include/scsi/scsi_transport_iscsi.h')
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index aab1eae2ec4c..f5444e033cc9 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -30,11 +30,11 @@ | |||
30 | 30 | ||
31 | struct scsi_transport_template; | 31 | struct scsi_transport_template; |
32 | struct iscsi_transport; | 32 | struct iscsi_transport; |
33 | struct iscsi_endpoint; | ||
33 | struct Scsi_Host; | 34 | struct Scsi_Host; |
34 | struct iscsi_cls_conn; | 35 | struct iscsi_cls_conn; |
35 | struct iscsi_conn; | 36 | struct iscsi_conn; |
36 | struct iscsi_cmd_task; | 37 | struct iscsi_task; |
37 | struct iscsi_mgmt_task; | ||
38 | struct sockaddr; | 38 | struct sockaddr; |
39 | 39 | ||
40 | /** | 40 | /** |
@@ -58,19 +58,22 @@ struct sockaddr; | |||
58 | * @stop_conn: suspend/recover/terminate connection | 58 | * @stop_conn: suspend/recover/terminate connection |
59 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. | 59 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. |
60 | * @session_recovery_timedout: notify LLD a block during recovery timed out | 60 | * @session_recovery_timedout: notify LLD a block during recovery timed out |
61 | * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs. | 61 | * @init_task: Initialize a iscsi_task and any internal structs. |
62 | * Called from queuecommand with session lock held. | 62 | * When offloading the data path, this is called from |
63 | * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs. | 63 | * queuecommand with the session lock, or from the |
64 | * Called from iscsi_conn_send_generic with xmitmutex. | 64 | * iscsi_conn_send_pdu context with the session lock. |
65 | * @xmit_cmd_task: Requests LLD to transfer cmd task. Returns 0 or the | 65 | * When not offloading the data path, this is called |
66 | * from the scsi work queue without the session lock. | ||
67 | * @xmit_task Requests LLD to transfer cmd task. Returns 0 or the | ||
66 | * the number of bytes transferred on success, and -Exyz | 68 | * the number of bytes transferred on success, and -Exyz |
67 | * value on error. | 69 | * value on error. When offloading the data path, this |
68 | * @xmit_mgmt_task: Requests LLD to transfer mgmt task. Returns 0 or the | 70 | * is called from queuecommand with the session lock, or |
69 | * the number of bytes transferred on success, and -Exyz | 71 | * from the iscsi_conn_send_pdu context with the session |
70 | * value on error. | 72 | * lock. When not offloading the data path, this is called |
71 | * @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex | 73 | * from the scsi work queue without the session lock. |
72 | * and session->lock after the connection has been | 74 | * @cleanup_task: requests LLD to fail task. Called with session lock |
73 | * suspended and terminated during recovery. If called | 75 | * and after the connection has been suspended and |
76 | * terminated during recovery. If called | ||
74 | * from abort task then connection is not suspended | 77 | * from abort task then connection is not suspended |
75 | * or terminated but sk_callback_lock is held | 78 | * or terminated but sk_callback_lock is held |
76 | * | 79 | * |
@@ -83,17 +86,9 @@ struct iscsi_transport { | |||
83 | /* LLD sets this to indicate what values it can export to sysfs */ | 86 | /* LLD sets this to indicate what values it can export to sysfs */ |
84 | uint64_t param_mask; | 87 | uint64_t param_mask; |
85 | uint64_t host_param_mask; | 88 | uint64_t host_param_mask; |
86 | struct scsi_host_template *host_template; | 89 | struct iscsi_cls_session *(*create_session) (struct iscsi_endpoint *ep, |
87 | /* LLD connection data size */ | 90 | uint16_t cmds_max, uint16_t qdepth, |
88 | int conndata_size; | 91 | uint32_t sn, uint32_t *hn); |
89 | /* LLD session data size */ | ||
90 | int sessiondata_size; | ||
91 | int max_lun; | ||
92 | unsigned int max_conn; | ||
93 | unsigned int max_cmd_len; | ||
94 | struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, | ||
95 | struct scsi_transport_template *t, uint16_t, uint16_t, | ||
96 | uint32_t sn, uint32_t *hn); | ||
97 | void (*destroy_session) (struct iscsi_cls_session *session); | 92 | void (*destroy_session) (struct iscsi_cls_session *session); |
98 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, | 93 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, |
99 | uint32_t cid); | 94 | uint32_t cid); |
@@ -118,20 +113,15 @@ struct iscsi_transport { | |||
118 | char *data, uint32_t data_size); | 113 | char *data, uint32_t data_size); |
119 | void (*get_stats) (struct iscsi_cls_conn *conn, | 114 | void (*get_stats) (struct iscsi_cls_conn *conn, |
120 | struct iscsi_stats *stats); | 115 | struct iscsi_stats *stats); |
121 | int (*init_cmd_task) (struct iscsi_cmd_task *ctask); | 116 | int (*init_task) (struct iscsi_task *task); |
122 | void (*init_mgmt_task) (struct iscsi_conn *conn, | 117 | int (*xmit_task) (struct iscsi_task *task); |
123 | struct iscsi_mgmt_task *mtask); | 118 | void (*cleanup_task) (struct iscsi_conn *conn, |
124 | int (*xmit_cmd_task) (struct iscsi_conn *conn, | 119 | struct iscsi_task *task); |
125 | struct iscsi_cmd_task *ctask); | ||
126 | void (*cleanup_cmd_task) (struct iscsi_conn *conn, | ||
127 | struct iscsi_cmd_task *ctask); | ||
128 | int (*xmit_mgmt_task) (struct iscsi_conn *conn, | ||
129 | struct iscsi_mgmt_task *mtask); | ||
130 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); | 120 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); |
131 | int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking, | 121 | struct iscsi_endpoint *(*ep_connect) (struct sockaddr *dst_addr, |
132 | uint64_t *ep_handle); | 122 | int non_blocking); |
133 | int (*ep_poll) (uint64_t ep_handle, int timeout_ms); | 123 | int (*ep_poll) (struct iscsi_endpoint *ep, int timeout_ms); |
134 | void (*ep_disconnect) (uint64_t ep_handle); | 124 | void (*ep_disconnect) (struct iscsi_endpoint *ep); |
135 | int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type, | 125 | int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type, |
136 | uint32_t enable, struct sockaddr *dst_addr); | 126 | uint32_t enable, struct sockaddr *dst_addr); |
137 | }; | 127 | }; |
@@ -172,9 +162,10 @@ enum { | |||
172 | ISCSI_SESSION_FREE, | 162 | ISCSI_SESSION_FREE, |
173 | }; | 163 | }; |
174 | 164 | ||
165 | #define ISCSI_MAX_TARGET -1 | ||
166 | |||
175 | struct iscsi_cls_session { | 167 | struct iscsi_cls_session { |
176 | struct list_head sess_list; /* item in session_list */ | 168 | struct list_head sess_list; /* item in session_list */ |
177 | struct list_head host_list; | ||
178 | struct iscsi_transport *transport; | 169 | struct iscsi_transport *transport; |
179 | spinlock_t lock; | 170 | spinlock_t lock; |
180 | struct work_struct block_work; | 171 | struct work_struct block_work; |
@@ -186,7 +177,7 @@ struct iscsi_cls_session { | |||
186 | int recovery_tmo; | 177 | int recovery_tmo; |
187 | struct delayed_work recovery_work; | 178 | struct delayed_work recovery_work; |
188 | 179 | ||
189 | int target_id; | 180 | unsigned int target_id; |
190 | 181 | ||
191 | int state; | 182 | int state; |
192 | int sid; /* session id */ | 183 | int sid; /* session id */ |
@@ -203,14 +194,22 @@ struct iscsi_cls_session { | |||
203 | #define starget_to_session(_stgt) \ | 194 | #define starget_to_session(_stgt) \ |
204 | iscsi_dev_to_session(_stgt->dev.parent) | 195 | iscsi_dev_to_session(_stgt->dev.parent) |
205 | 196 | ||
206 | struct iscsi_host { | 197 | struct iscsi_cls_host { |
207 | struct list_head sessions; | ||
208 | atomic_t nr_scans; | 198 | atomic_t nr_scans; |
209 | struct mutex mutex; | 199 | struct mutex mutex; |
210 | struct workqueue_struct *scan_workq; | 200 | struct workqueue_struct *scan_workq; |
211 | char scan_workq_name[KOBJ_NAME_LEN]; | 201 | char scan_workq_name[KOBJ_NAME_LEN]; |
212 | }; | 202 | }; |
213 | 203 | ||
204 | extern void iscsi_host_for_each_session(struct Scsi_Host *shost, | ||
205 | void (*fn)(struct iscsi_cls_session *)); | ||
206 | |||
207 | struct iscsi_endpoint { | ||
208 | void *dd_data; /* LLD private data */ | ||
209 | struct device dev; | ||
210 | unsigned int id; | ||
211 | }; | ||
212 | |||
214 | /* | 213 | /* |
215 | * session and connection functions that can be used by HW iSCSI LLDs | 214 | * session and connection functions that can be used by HW iSCSI LLDs |
216 | */ | 215 | */ |
@@ -222,22 +221,26 @@ struct iscsi_host { | |||
222 | 221 | ||
223 | extern int iscsi_session_chkready(struct iscsi_cls_session *session); | 222 | extern int iscsi_session_chkready(struct iscsi_cls_session *session); |
224 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, | 223 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, |
225 | struct iscsi_transport *transport); | 224 | struct iscsi_transport *transport, int dd_size); |
226 | extern int iscsi_add_session(struct iscsi_cls_session *session, | 225 | extern int iscsi_add_session(struct iscsi_cls_session *session, |
227 | unsigned int target_id); | 226 | unsigned int target_id); |
228 | extern int iscsi_session_event(struct iscsi_cls_session *session, | 227 | extern int iscsi_session_event(struct iscsi_cls_session *session, |
229 | enum iscsi_uevent_e event); | 228 | enum iscsi_uevent_e event); |
230 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, | 229 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, |
231 | struct iscsi_transport *t, | 230 | struct iscsi_transport *t, |
231 | int dd_size, | ||
232 | unsigned int target_id); | 232 | unsigned int target_id); |
233 | extern void iscsi_remove_session(struct iscsi_cls_session *session); | 233 | extern void iscsi_remove_session(struct iscsi_cls_session *session); |
234 | extern void iscsi_free_session(struct iscsi_cls_session *session); | 234 | extern void iscsi_free_session(struct iscsi_cls_session *session); |
235 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); | 235 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); |
236 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, | 236 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, |
237 | uint32_t cid); | 237 | int dd_size, uint32_t cid); |
238 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); | 238 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); |
239 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); | 239 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); |
240 | extern void iscsi_block_session(struct iscsi_cls_session *session); | 240 | extern void iscsi_block_session(struct iscsi_cls_session *session); |
241 | extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); | 241 | extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); |
242 | extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); | ||
243 | extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); | ||
244 | extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); | ||
242 | 245 | ||
243 | #endif | 246 | #endif |