diff options
Diffstat (limited to 'include/scsi/scsi_transport_iscsi.h')
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 119 |
1 files changed, 100 insertions, 19 deletions
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index b41cf077e54..b684426a590 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * iSCSI transport class definitions | 2 | * iSCSI transport class definitions |
3 | * | 3 | * |
4 | * Copyright (C) IBM Corporation, 2004 | 4 | * Copyright (C) IBM Corporation, 2004 |
5 | * Copyright (C) Mike Christie, 2004 - 2005 | 5 | * Copyright (C) Mike Christie, 2004 - 2006 |
6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 | 6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 |
7 | * Copyright (C) Alex Aizman, 2004 - 2005 | 7 | * Copyright (C) Alex Aizman, 2004 - 2005 |
8 | * | 8 | * |
@@ -27,9 +27,13 @@ | |||
27 | #include <scsi/iscsi_if.h> | 27 | #include <scsi/iscsi_if.h> |
28 | 28 | ||
29 | struct scsi_transport_template; | 29 | struct scsi_transport_template; |
30 | struct iscsi_transport; | ||
30 | struct Scsi_Host; | 31 | struct Scsi_Host; |
31 | struct mempool_zone; | 32 | struct mempool_zone; |
32 | struct iscsi_cls_conn; | 33 | struct iscsi_cls_conn; |
34 | struct iscsi_conn; | ||
35 | struct iscsi_cmd_task; | ||
36 | struct iscsi_mgmt_task; | ||
33 | 37 | ||
34 | /** | 38 | /** |
35 | * struct iscsi_transport - iSCSI Transport template | 39 | * struct iscsi_transport - iSCSI Transport template |
@@ -46,6 +50,24 @@ struct iscsi_cls_conn; | |||
46 | * @start_conn: set connection to be operational | 50 | * @start_conn: set connection to be operational |
47 | * @stop_conn: suspend/recover/terminate connection | 51 | * @stop_conn: suspend/recover/terminate connection |
48 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. | 52 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. |
53 | * @session_recovery_timedout: notify LLD a block during recovery timed out | ||
54 | * @suspend_conn_recv: susepend the recv side of the connection | ||
55 | * @termincate_conn: destroy socket connection. Called with mutex lock. | ||
56 | * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs. | ||
57 | * Called from queuecommand with session lock held. | ||
58 | * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs. | ||
59 | * Called from iscsi_conn_send_generic with xmitmutex. | ||
60 | * @xmit_cmd_task: Requests LLD to transfer cmd task. Returns 0 or the | ||
61 | * the number of bytes transferred on success, and -Exyz | ||
62 | * value on error. | ||
63 | * @xmit_mgmt_task: Requests LLD to transfer mgmt task. Returns 0 or the | ||
64 | * the number of bytes transferred on success, and -Exyz | ||
65 | * value on error. | ||
66 | * @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex | ||
67 | * and session->lock after the connection has been | ||
68 | * suspended and terminated during recovery. If called | ||
69 | * from abort task then connection is not suspended | ||
70 | * or terminated but sk_callback_lock is held | ||
49 | * | 71 | * |
50 | * Template API provided by iSCSI Transport | 72 | * Template API provided by iSCSI Transport |
51 | */ | 73 | */ |
@@ -53,38 +75,58 @@ struct iscsi_transport { | |||
53 | struct module *owner; | 75 | struct module *owner; |
54 | char *name; | 76 | char *name; |
55 | unsigned int caps; | 77 | unsigned int caps; |
78 | /* LLD sets this to indicate what values it can export to sysfs */ | ||
79 | unsigned int param_mask; | ||
56 | struct scsi_host_template *host_template; | 80 | struct scsi_host_template *host_template; |
57 | /* LLD session/scsi_host data size */ | ||
58 | int hostdata_size; | ||
59 | /* LLD iscsi_host data size */ | ||
60 | int ihostdata_size; | ||
61 | /* LLD connection data size */ | 81 | /* LLD connection data size */ |
62 | int conndata_size; | 82 | int conndata_size; |
83 | /* LLD session data size */ | ||
84 | int sessiondata_size; | ||
63 | int max_lun; | 85 | int max_lun; |
64 | unsigned int max_conn; | 86 | unsigned int max_conn; |
65 | unsigned int max_cmd_len; | 87 | unsigned int max_cmd_len; |
66 | struct iscsi_cls_session *(*create_session) | 88 | struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, |
67 | (struct scsi_transport_template *t, uint32_t sn, uint32_t *sid); | 89 | struct scsi_transport_template *t, uint32_t sn, uint32_t *hn); |
68 | void (*destroy_session) (struct iscsi_cls_session *session); | 90 | void (*destroy_session) (struct iscsi_cls_session *session); |
69 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, | 91 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, |
70 | uint32_t cid); | 92 | uint32_t cid); |
71 | int (*bind_conn) (struct iscsi_cls_session *session, | 93 | int (*bind_conn) (struct iscsi_cls_session *session, |
72 | struct iscsi_cls_conn *cls_conn, | 94 | struct iscsi_cls_conn *cls_conn, |
73 | uint32_t transport_fd, int is_leading); | 95 | uint64_t transport_eph, int is_leading); |
74 | int (*start_conn) (struct iscsi_cls_conn *conn); | 96 | int (*start_conn) (struct iscsi_cls_conn *conn); |
75 | void (*stop_conn) (struct iscsi_cls_conn *conn, int flag); | 97 | void (*stop_conn) (struct iscsi_cls_conn *conn, int flag); |
76 | void (*destroy_conn) (struct iscsi_cls_conn *conn); | 98 | void (*destroy_conn) (struct iscsi_cls_conn *conn); |
77 | int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param, | 99 | int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param, |
78 | uint32_t value); | 100 | uint32_t value); |
79 | int (*get_conn_param) (struct iscsi_cls_conn *conn, | 101 | int (*get_conn_param) (struct iscsi_cls_conn *conn, |
80 | enum iscsi_param param, | 102 | enum iscsi_param param, uint32_t *value); |
81 | uint32_t *value); | ||
82 | int (*get_session_param) (struct iscsi_cls_session *session, | 103 | int (*get_session_param) (struct iscsi_cls_session *session, |
83 | enum iscsi_param param, uint32_t *value); | 104 | enum iscsi_param param, uint32_t *value); |
105 | int (*get_conn_str_param) (struct iscsi_cls_conn *conn, | ||
106 | enum iscsi_param param, char *buf); | ||
107 | int (*get_session_str_param) (struct iscsi_cls_session *session, | ||
108 | enum iscsi_param param, char *buf); | ||
84 | int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, | 109 | int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, |
85 | char *data, uint32_t data_size); | 110 | char *data, uint32_t data_size); |
86 | void (*get_stats) (struct iscsi_cls_conn *conn, | 111 | void (*get_stats) (struct iscsi_cls_conn *conn, |
87 | struct iscsi_stats *stats); | 112 | struct iscsi_stats *stats); |
113 | void (*suspend_conn_recv) (struct iscsi_conn *conn); | ||
114 | void (*terminate_conn) (struct iscsi_conn *conn); | ||
115 | void (*init_cmd_task) (struct iscsi_cmd_task *ctask); | ||
116 | void (*init_mgmt_task) (struct iscsi_conn *conn, | ||
117 | struct iscsi_mgmt_task *mtask, | ||
118 | char *data, uint32_t data_size); | ||
119 | int (*xmit_cmd_task) (struct iscsi_conn *conn, | ||
120 | struct iscsi_cmd_task *ctask); | ||
121 | void (*cleanup_cmd_task) (struct iscsi_conn *conn, | ||
122 | struct iscsi_cmd_task *ctask); | ||
123 | int (*xmit_mgmt_task) (struct iscsi_conn *conn, | ||
124 | struct iscsi_mgmt_task *mtask); | ||
125 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); | ||
126 | int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking, | ||
127 | uint64_t *ep_handle); | ||
128 | int (*ep_poll) (uint64_t ep_handle, int timeout_ms); | ||
129 | void (*ep_disconnect) (uint64_t ep_handle); | ||
88 | }; | 130 | }; |
89 | 131 | ||
90 | /* | 132 | /* |
@@ -100,10 +142,26 @@ extern void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error); | |||
100 | extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, | 142 | extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, |
101 | char *data, uint32_t data_size); | 143 | char *data, uint32_t data_size); |
102 | 144 | ||
145 | |||
146 | /* Connection's states */ | ||
147 | #define ISCSI_CONN_INITIAL_STAGE 0 | ||
148 | #define ISCSI_CONN_STARTED 1 | ||
149 | #define ISCSI_CONN_STOPPED 2 | ||
150 | #define ISCSI_CONN_CLEANUP_WAIT 3 | ||
151 | |||
103 | struct iscsi_cls_conn { | 152 | struct iscsi_cls_conn { |
104 | struct list_head conn_list; /* item in connlist */ | 153 | struct list_head conn_list; /* item in connlist */ |
105 | void *dd_data; /* LLD private data */ | 154 | void *dd_data; /* LLD private data */ |
106 | struct iscsi_transport *transport; | 155 | struct iscsi_transport *transport; |
156 | uint32_t cid; /* connection id */ | ||
157 | |||
158 | /* portal/group values we got during discovery */ | ||
159 | char *persistent_address; | ||
160 | int persistent_port; | ||
161 | /* portal/group values we are currently using */ | ||
162 | char *address; | ||
163 | int port; | ||
164 | |||
107 | int active; /* must be accessed with the connlock */ | 165 | int active; /* must be accessed with the connlock */ |
108 | struct device dev; /* sysfs transport/container device */ | 166 | struct device dev; /* sysfs transport/container device */ |
109 | struct mempool_zone *z_error; | 167 | struct mempool_zone *z_error; |
@@ -114,9 +172,32 @@ struct iscsi_cls_conn { | |||
114 | #define iscsi_dev_to_conn(_dev) \ | 172 | #define iscsi_dev_to_conn(_dev) \ |
115 | container_of(_dev, struct iscsi_cls_conn, dev) | 173 | container_of(_dev, struct iscsi_cls_conn, dev) |
116 | 174 | ||
175 | /* Session's states */ | ||
176 | #define ISCSI_STATE_FREE 1 | ||
177 | #define ISCSI_STATE_LOGGED_IN 2 | ||
178 | #define ISCSI_STATE_FAILED 3 | ||
179 | #define ISCSI_STATE_TERMINATE 4 | ||
180 | #define ISCSI_STATE_IN_RECOVERY 5 | ||
181 | #define ISCSI_STATE_RECOVERY_FAILED 6 | ||
182 | |||
117 | struct iscsi_cls_session { | 183 | struct iscsi_cls_session { |
118 | struct list_head sess_list; /* item in session_list */ | 184 | struct list_head sess_list; /* item in session_list */ |
185 | struct list_head host_list; | ||
119 | struct iscsi_transport *transport; | 186 | struct iscsi_transport *transport; |
187 | |||
188 | /* iSCSI values used as unique id by userspace. */ | ||
189 | char *targetname; | ||
190 | int tpgt; | ||
191 | |||
192 | /* recovery fields */ | ||
193 | int recovery_tmo; | ||
194 | struct work_struct recovery_work; | ||
195 | |||
196 | int target_id; | ||
197 | int channel; | ||
198 | |||
199 | int sid; /* session id */ | ||
200 | void *dd_data; /* LLD private data */ | ||
120 | struct device dev; /* sysfs transport/container device */ | 201 | struct device dev; /* sysfs transport/container device */ |
121 | }; | 202 | }; |
122 | 203 | ||
@@ -126,22 +207,22 @@ struct iscsi_cls_session { | |||
126 | #define iscsi_session_to_shost(_session) \ | 207 | #define iscsi_session_to_shost(_session) \ |
127 | dev_to_shost(_session->dev.parent) | 208 | dev_to_shost(_session->dev.parent) |
128 | 209 | ||
210 | struct iscsi_host { | ||
211 | int next_target_id; | ||
212 | struct list_head sessions; | ||
213 | struct mutex mutex; | ||
214 | }; | ||
215 | |||
129 | /* | 216 | /* |
130 | * session and connection functions that can be used by HW iSCSI LLDs | 217 | * session and connection functions that can be used by HW iSCSI LLDs |
131 | */ | 218 | */ |
132 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, | 219 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, |
133 | struct iscsi_transport *t); | 220 | struct iscsi_transport *t, int channel); |
134 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); | 221 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); |
135 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, | 222 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, |
136 | uint32_t cid); | 223 | uint32_t cid); |
137 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); | 224 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); |
138 | 225 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); | |
139 | /* | 226 | extern void iscsi_block_session(struct iscsi_cls_session *session); |
140 | * session functions used by software iscsi | ||
141 | */ | ||
142 | extern struct Scsi_Host * | ||
143 | iscsi_transport_create_session(struct scsi_transport_template *scsit, | ||
144 | struct iscsi_transport *transport); | ||
145 | extern int iscsi_transport_destroy_session(struct Scsi_Host *shost); | ||
146 | 227 | ||
147 | #endif | 228 | #endif |